QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#737544 | #9717. Defuse the Bombs | ckq328 | WA | 35ms | 6540kb | C++20 | 728b | 2024-11-12 16:08:49 | 2024-11-12 16:08:49 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e6+10,M=200+10,inf=1e18,mod=998244353;
int n,tot;
int a[N],b[N];
void solve(){
int n;
cin>>n;
for(int i=1;i<=n;i++) cin>>a[i];
sort(a+1,a+1+n);
for(int i=1;i<=n;i++) b[i]=b[i-1]+a[i];
cout<<"Case #"<<(++tot)<<": ";
int len=1,h=0;
for(int i=2;i<=n;i++){
if(i==n){
if(n==2) h=a[2]+a[1];
else h+=(a[1]-((n-1)*a[n]-b[n]+b[1]))/(n-1);
}
else{
if(a[i+1]*(i-1)<=a[1]+b[i]-b[1]){
h=a[i+1];
continue;
}
else{
break;
}
}
}
cout<<h+1<<endl;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int tt;
cin>>tt;
// tt=1;
while(tt--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5700kb
input:
2 2 1 1 3 1 2 3
output:
Case #1: 3 Case #2: 4
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 32ms
memory: 6428kb
input:
3 100000 968870229 246637522 23867348 170512761 317727561 135784257 788061221 6692201 96102115 164513402 826612817 675345177 690177641 969959105 957765211 678805726 936166573 281739681 760822473 521447491 619742216 102531432 633299481 698320991 55968513 399427883 808303141 53228160 432641457 7250014...
output:
Case #1: 2 Case #2: 2 Case #3: 2
result:
ok 3 lines
Test #3:
score: -100
Wrong Answer
time: 35ms
memory: 6540kb
input:
12 99648 868508085 197551137 223963681 271716447 485636149 768477451 637746433 290912601 973354817 623217611 874717425 808610975 631236945 908326401 17087606 254068257 960429731 968635649 947450738 601921026 102237601 99225633 898941536 107413793 100995151 226235470 853952217 829469697 126588881 821...
output:
Case #1: 2 Case #2: 69362 Case #3: 2 Case #4: 2 Case #5: 2 Case #6: 1 Case #7: 1 Case #8: 2 Case #9: 3750802 Case #10: 1036767035 Case #11: 1 Case #12: 1
result:
wrong answer 2nd lines differ - expected: 'Case #2: 71597', found: 'Case #2: 69362'