Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
code_chef
#include <bits/stdc++.h> using namespace std; int main() { int t,n; cin>>t; while(t--) { cin>>n; int a[n],f[n],b[n],s,min; s=0; for(int i=0;i<n;i++) { cin>>a[i]; s+=a[i]; f[i]=s; } min=0; b[0] = f[0]+f[n-1]; for(int i=1;i<n;i++) { b[i] = f[i]+f[n-1]-f[i-1]; if(b[i] < b[min]) min=i; } /* min= *min_element(b,b+n); for(int i=0;i<n;i++) { if(b[i]==min){ min=i+1; break; } } */ cout<<min+1<<"\n"; } }
run
|
edit
|
history
|
help
0
Testing C++
CutRod
lambda demo
cppbasic
Expected types
queue
Khadijah Alshehhi
sample
begin_end.cpp
temp