Submission #94138

# Submission time Handle Problem Language Result Execution time Memory
94138 2019-01-16T11:33:04 Z bkinik Nizin (COCI16_nizin) C++11
100 / 100
160 ms 8184 KB
#include<bits/stdc++.h>
using namespace std;

#define pob pop_back
#define mp make_pair
#define pb push_back
#define mid (l+r)/2
#define test printf("test\n")
#define st first
#define nd second
#define superman ios::sync_with_stdio(0);cin.tie(0);

typedef long long ll;
typedef pair<ll,ll> pll;

ll INF = 1e9;
ll mod = 1e9+7;
double pi = acos(-1);

ll l,k,m,n,ans,r;

vector<ll> nums;
ll leftnum, rightnum;
ll lp,rp;
int main() {
	//freopen(".gir","r",stdin);
	//freopen(".cik","w",stdout);
	cin>>n;
	lp = 0; rp = n-1;
	nums.resize(n);
	for(int i=0; i<n; i++) {
		cin>>nums[i];
	}
	leftnum = nums[0];
	rightnum = nums[n-1];

	while(lp < rp) {
		if(leftnum == rightnum) {
			lp++;
			rp--;
			leftnum = nums[lp];
			rightnum = nums[rp];
			continue;
		}
		else {
			if(leftnum < rightnum) {
				lp++;
				leftnum += nums[lp];
			}
			else {
				rp--;
				rightnum += nums[rp];
			}
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;

}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 1016 KB Output is correct
2 Correct 17 ms 1144 KB Output is correct
3 Correct 17 ms 1144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 3080 KB Output is correct
2 Correct 68 ms 3692 KB Output is correct
3 Correct 79 ms 4216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 119 ms 6264 KB Output is correct
2 Correct 126 ms 6520 KB Output is correct
3 Correct 148 ms 7396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 157 ms 8056 KB Output is correct
2 Correct 159 ms 8184 KB Output is correct
3 Correct 160 ms 8184 KB Output is correct