Skip to content

Instantly share code, notes, and snippets.

@qjatn0120
Created September 8, 2022 17:15
Show Gist options
  • Save qjatn0120/5c74dd0d0c22d0682fcd3789ccde3d89 to your computer and use it in GitHub Desktop.
Save qjatn0120/5c74dd0d0c22d0682fcd3789ccde3d89 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
int t, n, cnt[25], sum, ans;
int main(){
cin.tie(nullptr), ios::sync_with_stdio(false);
cin >> t;
while(t--){
cin >> n;
sum = 0;
for(int i = 0; i < n; i++){
cin >> cnt[i];
sum += cnt[i];
}
ans = 1;
for(int i = 0; i < n; i++){
if(cnt[i] > sum / 2) ans = i + 1;
}
cout << ans << "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment