Submission #245277

# Submission time Handle Problem Language Result Execution time Memory
245277 2020-07-05T22:31:07 Z Ort Preokret (COCI19_preokret) C++11
50 / 50
5 ms 436 KB
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
#define mem(a, b) memset(a, (b), sizeof(a))
#define all(c) (c).begin(),(c).end()
#define sz(a) ((int)(a.size()))
#define ll long long
#define linf (ll)1e18
#define inf (int)1e9
#define minf 0x3F3F3F3F
#define pb push_back
#define fs first
#define sc second
#define mp make_pair
#define mod 1000000007
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAX 200005
#define watch(x) cerr<<#x<<" = "<<(x)<<endl;

using namespace std;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll n, city, enemy, big, ti, g, lastc, laste;

int main() {
	IO;
	
	cin >> n;
	ti++;
	
	for(int i=1;i<=n;i++) {
		cin >> g;
		
		if(g==1) lastc = i;
		if(g==2) laste = i;
		
		if(g==1) city++;
		else enemy++;
		if(city==enemy) ti++;
		
		if(city>enemy) {
			big = max(big, i-laste);
		}
		if(city<enemy) {
			big = max(big, i-lastc);
		}
		
		
	}
	
	cout << city << " " << enemy << "\n";
	cout << ti << "\n" << big;

	return 0;
}


# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 436 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct