图灵乒乓1214专用

刘宸志 CEUA  •  2年前


include<bits/stdc++.h>

using namespace std;

int main(){

int n,a[200005],sum=1;
cin>>n;
for(int i=1;i<=n;i++)
	cin>>a[i];
sort(a+1,a+n+1);
for(int i=2;i<=n+1;i++){
	if(a[i]==a[i-1])
		sum++;
	else{
		cout<<a[i-1]<<' '<<sum<<endl;
		sum=1;
	}
}
return 0;

}


评论:

include<bits/stdc++.h>

using namespace std;

int main() {

int a[10010],ci,n;
cin>>n;
for(int i=1;i<=n;i++)
	cin>>a[i];
sort(a+1,a+n+1);
cout<<a[n/2+1];
return 0;

}


刘宸志 CEUA  •  2年前

include <bits/stdc++.h>

using namespace std; int a[10010];

int main() {

int n, x;
cin >> n;
for (int i = 0; i < n; i++)
	cin >> a[i];
cin >> x;
for (int i = 0; i < n; i++) {
	if (a[i] >= x) {
		cout << x << " ";
		x = 999999999;
	}
	cout << a[i] << " ";
}
if (x != 999999999)
	cout << x;
return 0;

}


刘谦  •  2年前

include

include

using namespace std;

int n, m, atime[2][20][20], ans[2][100000], ans_num[2];

void func(int people, int locate, int cost) {

if (locate == n) {
	ans[people][ans_num[people]] = cost;
	ans_num[people]++;
	return ;
}
for (int i = locate + 1; i <= n; i++) {
	if (atime[people][locate][i]) {
		func(people, i, cost + atime[people][locate][i]);
	}
}

}

int main() {

cin >> n >> m;
for (int i = 0; i < m; i++) {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	atime[0][a][b] = atime[0][b][a] = c;
	atime[1][a][b] = atime[1][b][a] = d;
}
func(0, 1, 0);
func(1, 1, 0);
sort(ans[0], ans[0] + ans_num[0]);
sort(ans[1], ans[1] + ans_num[1]);
for (int i = 0; i < ans_num[0]; i++) {
	for (int j = 0; j < ans_num[1]; j++) {
		if (ans[0][i] == ans[1][j]) {
			cout << ans[0][i] << endl;
			return 0;
		}
	}
}
cout << "IMPOSSIBLE" << endl;

return 0;

}


刘谦  •  2年前

请先登录,才能进行评论