-
Notifications
You must be signed in to change notification settings - Fork 2
/
MINVOTE2.cpp
71 lines (70 loc) · 1.6 KB
/
MINVOTE2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include<bits/stdc++.h>
using namespace std;
int main()
{
long int t;
cin>>t;
while(t--)
{
long int n;
scanf("%ld",&n);
vector<long int> arr(n);
// vector<long int> fs;
// vector<long int> bs;
vector<long int> sum(n+1,0);
vector<long int> ans(n+2,0);
// vector<long int> ans1(n,0);
for(long int i=0;i<n;i++)
{
scanf("%ld",&arr[i]);
sum[i+1]=sum[i]+arr[i];
}
bool flag=1;
for(long int i=0;i<n-1;i++)
{
for(long int j=i+1;j<n;j++)
{
if(sum[j]-sum[i+1]>arr[i])
{
ans[i+1]+=1;
ans[j]-=1;
flag=0;
break;
}
}
if(flag)
{
ans[i+1]+=1;
ans[n]-=1;
}
flag=1;
}
flag=1;
for(long int i=n-1;i>0;i--)
{
for(long int j=i-1;j>=0;j--)
{
if(sum[i]-sum[j+1]>arr[i])
{
ans[j+1]+=1;
ans[i]-=1;
flag=0;
break;
}
}
if(flag)
{
ans[0]+=1;
ans[i]-=1;
}
flag=1;
}
for(long int i=1;i<=n+1;i++)
ans[i]+=ans[i-1];
// cout<<ans1[n-1];
// cout<<endl;
for(long int i=0;i<n;i++)
cout<<ans[i]<<" ";
cout<<endl;
}
}