社区讨论
洛谷上测60 公示分数0是为什么
P14361[CSP-S 2025] 社团招新参与者 11已保存回复 12
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 12 条
- 当前快照
- 1 份
- 快照标识符
- @mhqm4cte
- 此快照首次捕获于
- 2025/11/09 02:23 4 个月前
- 此快照最后确认于
- 2025/11/16 14:22 4 个月前
洛谷上测60
公示分数0是为什么
CPP#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+100;
int d[N], a[N][5], maxt[N];
int ans;
void solve(){
int n, cnt1, cnt2, cnt3;
cnt1 = cnt2 = cnt3 = ans = 0;
memset(a, 0, sizeof(a));
cin>>n;
int k = n/2;
for(int i = 1; i <= n; i++){
cin>>a[i][1]>>a[i][2]>>a[i][3];
ans += max(max(a[i][1], a[i][2]), a[i][3]);
if(a[i][1] > a[i][2] && a[i][1] > a[i][3]) cnt1++, maxt[i] = 1;
if(a[i][2] > a[i][1] && a[i][2] > a[i][3]) cnt2++, maxt[i] = 2;
if(a[i][3] > a[i][2] && a[i][3] > a[i][1]) cnt3++, maxt[i] = 3;
d[i] = 2e4+500;
}
int p = -1;
if(cnt1 > k) p = 1;
if(cnt2 > k) p = 2;
if(cnt3 > k) p = 3;
if(p == -1){
cout<<ans<<"\n";
return ;
}
if(p == 1){
for(int i = 1; i <= n; i++)
if(maxt[i] == 1)
d[i] = min(a[i][1]-a[i][2], a[i][1]-a[i][3]);
sort(d+1, d+1+n);
for(int i = 1; i <= cnt1-k; i++) ans -= d[i];
cout<<ans<<"\n";
return ;
}
if(p == 2){
for(int i = 1; i <= n; i++)
if(maxt[i] == 2)
d[i] = min(a[i][2]-a[i][1], a[i][2]-a[i][3]);
sort(d+1, d+1+n);
for(int i = 1; i <= cnt2-k; i++) ans -= d[i];
cout<<ans<<"\n";
return ;
}
if(p == 3){
for(int i = 1; i <= n; i++)
if(maxt[i] == 3)
d[i] = min(a[i][3]-a[i][1], a[i][3]-a[i][2]);
sort(d+1, d+1+n);
for(int i = 1; i <= cnt3-k; i++) ans -= d[i];
cout<<ans<<"\n";
return ;
}
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
freopen("club.in", "r", stdin);
freopen("club.out ", "w", stdout);
int T;
cin>>T;
while(T--) solve();
return 0;
}
回复
共 12 条回复,欢迎继续交流。
正在加载回复...