Submission #210414

# Submission time Handle Problem Language Result Execution time Memory
210414 2020-03-17T10:07:39 Z Fasho Nizin (COCI16_nizin) C++14
100 / 100
84 ms 25848 KB
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
#define ull unsigned long long int
using namespace std;

ll n,m,ar[N],sum,t,suf[N],pref[N];



int main()
{
	fast;
	cin>>n;
	fs(ar,n);
	int l=1,r=n;
	ll a=0,b=0;
	fo(i,1,n)
	pref[i]=pref[i-1]+ar[i];
	for(int i=n;i>=1;i--)
		suf[i]=suf[i+1]+ar[i];
	while(l<r)
	{
		// cout<<l<<sp<<r<<endl;
		a=pref[l];
		b=suf[r];
		if(a!=b)
			sum++;
		if(a<=b)
			l++;
		if(b<=a)
			r--;
	}		
	cout<<sum;
}

# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 380 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 380 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 2296 KB Output is correct
2 Correct 12 ms 2808 KB Output is correct
3 Correct 12 ms 2936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 9208 KB Output is correct
2 Correct 40 ms 11256 KB Output is correct
3 Correct 42 ms 13176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 19704 KB Output is correct
2 Correct 71 ms 20728 KB Output is correct
3 Correct 73 ms 23288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 81 ms 25464 KB Output is correct
2 Correct 84 ms 25848 KB Output is correct
3 Correct 83 ms 25848 KB Output is correct