Submission #94159

# Submission time Handle Problem Language Result Execution time Memory
94159 2019-01-16T12:05:46 Z quoriess Nizin (COCI16_nizin) C++14
70 / 100
375 ms 66560 KB
#include <bits/stdc++.h>
#include <unistd.h>
#include <set>
#define dbg(x) cout<<#x<<" has a value of: "<<x<<"\n";
typedef long long int lli;      
using namespace std;
typedef pair<lli,lli> pii;
int main(){
	int n;
	cin>>n;
	vector<lli> dizi(n);
	for (int i = 0; i < n; i++)
	{
		cin>>dizi[i];
	}
	vector<lli> fromleft(n),fromright(n);
	int h=0;
	int hk=0;
	map<lli,pii> matches;
	for (int i = 0; i < n; i++)
	{
		h+=dizi[i];
		fromleft[i]=h;
		hk+=dizi[n-i-1];
		fromright[i]=hk;
	}
	for (int i = 0; i < n; i++)
	{
		if(matches.find(fromleft[i])==matches.end())matches[fromleft[i]]=pii(-1,-1);
		if(matches.find(fromright[i])==matches.end())matches[fromright[i]]=pii(-1,-1);
		matches[fromleft[i]].first=i;
		matches[fromright[i]].second=n-i-1;
	}
	lli cvb=0;
	int lv=-1,rv=n;
	for(auto x:matches){
		//dbg(x.first);
		//cout<<x.second.first<<"-"<<x.second.second<<"\n";
		if(x.second.first!=-1 && x.second.second!=-1){
			if(x.second.first==rv-1&& x.second.second==lv+1){
				cvb+=rv-2-lv;
				break;
			}
			cvb+=max(x.second.first-lv-1,0ll)+max(rv-x.second.second-1,0ll);
			lv=x.second.first;
			rv=x.second.second;
			if(lv==rv-1)break;
		}
	}
	cout<<cvb<<"\n";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 352 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 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 2 ms 404 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 11040 KB Output is correct
2 Correct 67 ms 13856 KB Output is correct
3 Correct 74 ms 14072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 295 ms 47852 KB Output is correct
2 Correct 368 ms 58624 KB Output is correct
3 Runtime error 353 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 375 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 373 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -