-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathminvote.cpp
32 lines (32 loc) · 877 Bytes
/
minvote.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
#include<iostream>
using namespace std;
int main(){
int test_case;
cin >> test_case;
while(test_case--){
int n;
cin >> n;
int *arr = new int[n];
int *vote = new int[n];
for(int i = 0; i < n; ++i){
cin >> arr[i];
vote[i] = 0;
}
for(int i = 0; i < n; ++i){
for(int right_sum = 0,right = i+1;right < n && right_sum <= arr[i];){
vote[right]++;
right++;
if(right > i+1)right_sum+=arr[right-1];
}
for(int left_sum = 0,left = i-1;left >= 0 && left_sum <= arr[i];){
vote[left]++;
left--;
if(left < i-1)left_sum+=arr[left+1];
}
}
for(int i = 0; i < n; ++i){
cout << vote[i] << " ";
}
cout << endl;
}
}