ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#207149 | #3733. 切数游戏 | ylq0221 | 100 | 102ms | 1916kb | C++11 | 491b | 2024-07-27 18:14:18 | 2024-07-27 20:04:54 |
answer
#include <bits/stdc++.h>
using namespace std;
int a[100005],s[100005];
int main(){
int n,sum=0,f=1,cnt=0;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
sum+=a[i];
if(a[i]<=0) f=0;
s[i]=s[i-1]+a[i];
}
if(sum%3!=0) cout<<0;
else if(sum%3==0&&f) cout<<1;
else{
int pos=0;
for(int i=1;i<n-1;i++){
if(s[i]==(sum/3)){
for(int j=i;j<n;j++){
if((s[j]-s[i])==(sum/3)&&(s[n]-s[j])==(sum/3))
cnt++;
}
}
}
cout<<cnt;
}
return 0;
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1204kb
input:
486 0 -7035 -3680 -8556 -2590 2202 1857 707 6059 -6910 6232 -474 -5627 9197 -7210 -373 5757 -8063 -1...
output:
22
result:
ok 1 number(s): "22"
Test #2:
score: 10
Accepted
time: 0ms
memory: 1208kb
input:
540 0 -9304 7419 1885 0 0 -4189 4189 0 -5574 -63 2547 3090 -5671 1678 3993 -1943 1943 -3720 3720 -73...
output:
16
result:
ok 1 number(s): "16"
Test #3:
score: 10
Accepted
time: 0ms
memory: 1208kb
input:
990 -6697 -298 -5157 -6137 1763 5159 -4902 7561 -6985 5504 -7844 -1671 -5404 -3509 -971 6878 -9921 4...
output:
20
result:
ok 1 number(s): "20"
Test #4:
score: 10
Accepted
time: 0ms
memory: 1208kb
input:
630 0 -7062 -6055 2567 -6899 -599 9773 -8779 576 -9134 3776 -3934 -1074 4865 3939 -5259 -4047 -2572 ...
output:
32
result:
ok 1 number(s): "32"
Test #5:
score: 10
Accepted
time: 0ms
memory: 1204kb
input:
792 -2222 -2246 -3382 1589 -3578 6591 -2788 -4561 -6833 -4695 -2470 3695 -45 -6683 -9801 -4794 -2788...
output:
40
result:
ok 1 number(s): "40"
Test #6:
score: 10
Accepted
time: 23ms
memory: 1780kb
input:
73962 -8321 3501 1816 3004 -1996 316 -4750 -7105 6173 -7364 -5192 6625 5770 7523 -5256 -7558 9528 32...
output:
4503
result:
ok 1 number(s): "4503"
Test #7:
score: 10
Accepted
time: 13ms
memory: 1640kb
input:
55620 0 -4501 4501 -2321 2321 0 -4073 4073 -1088 -1771 2859 -16 -325 341 0 -6666 4763 1903 0 0 0 0 0...
output:
115
result:
ok 1 number(s): "115"
Test #8:
score: 10
Accepted
time: 21ms
memory: 1716kb
input:
65970 -5847 -144 81 -2599 -307 6587 -4046 1206 2165 -424 -1174 4502 -7115 -6564 6954 3264 -8717 4248...
output:
3024
result:
ok 1 number(s): "3024"
Test #9:
score: 10
Accepted
time: 16ms
memory: 1644kb
input:
56610 0 0 0 0 0 -7041 -7721 -5889 -3636 5526 -9355 5573 -7402 -8503 -3252 -6336 -2090 1968 -2272 -37...
output:
2072
result:
ok 1 number(s): "2072"
Test #10:
score: 10
Accepted
time: 29ms
memory: 1916kb
input:
91782 -8103 -776 -4315 -4322 -751 -4423 -1397 9170 -6972 5484 -9303 5869 2194 -5814 -4022 7005 9963 ...
output:
8463
result:
ok 1 number(s): "8463"