Untitled
unknown
plain_text
a year ago
629 B
4
Indexable
Never
#include <fstream> using namespace std; ifstream fin("summit.in"); ofstream fout("summit.out"); long long n,b[1000001],x; int CB(int n,int i) { int st=1, dr=i; while(st<=dr) { int mij=st+(dr-st)/2; if(b[mij]==n) return mij; else if(b[mij]<n) st=mij+1; else dr=mij-1; } return 0; } void citire() { fin>>n; for(int i=1;i<=n;i++) { fin>>x; b[i]=b[i-1]+x; int y=CB(x,i); if(b[y]==x) fout<<y<<'\n'; else fout<<0<<'\n'; } } int main() { citire(); return 0; }