社区讨论
还能再短吗?
P11231[CSP-S 2024] 决斗参与者 7已保存回复 14
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 13 条
- 当前快照
- 1 份
- 快照标识符
- @m2rhogee
- 此快照首次捕获于
- 2024/10/27 19:10 去年
- 此快照最后确认于
- 2025/11/04 23:42 4 个月前
老板,真的不能再压缩了~
极致压缩版
CPP#include <bits/stdc++.h>
using namespace std;int n,r[100001],a=0,b=0;main(){cin>>n;for(int i = 0;i<n;i++)cin>>r[i];sort(r,r+n);while(a<n){if(r[a]>r[b])b++;a++;}cout<<n-b;return 0;}
正常版
CPP#include <bits/stdc++.h>
using namespace std;
int n, r[100001], a=0, b=0;
int main() {
cin >> n;
for (int i = 0; i<n; i++)
cin >> r[i];
sort(r, r+n);
while (a<n) {
if (r[a] > r[b])
b++;
a++;
}
cout << n-b;
return 0;
}
回复
共 14 条回复,欢迎继续交流。
正在加载回复...