# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
284464 | 2020-08-27T12:26:47 Z | PedroBigMan | Preokret (COCI19_preokret) | C++14 | 1 ms | 384 KB |
#include <iostream> #include <vector> #include <cmath> #include <algorithm> #include <string> #include <map> #include <unordered_map> #include <set> #include <unordered_set> #include <queue> #include <deque> #include <list> #include <iomanip> #include <stdlib.h> #include <time.h> using namespace std; typedef long long int ll; typedef unsigned long long int ull; typedef long double ld; #define REP(i,a,b) for(ll i=a; i<b; i++) #define pb push_back #define mp make_pair #define pl pair<ll,ll> #define ff first #define ss second #define whole(x) x.begin(),x.end() #define DEBUG(i) cout<<"Pedro Is The Master "<<i<<endl #define INF 5000000000000000000LL template<class A=ll> void Out(vector<A> a) {REP(i,0,a.size()) {cout<<a[i]<<" ";} cout<<endl;} template<class A=ll> void In(vector<A> &a, ll N) {A cur; REP(i,0,N) {cin>>cur; a.pb(cur);}} int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll N; cin>>N; int cur; pl score = mp(0,0); ll ties=1LL; ll las=-1; vector<pl> turns; REP(i,0,N) { cin>>cur; if(cur!=las) {turns.pb(score);} if(cur==1) {score.ff++;} else {score.ss++;} if(score.ff==score.ss) {ties++;} if(cur!=las) {turns.pb(score);} las=cur; } turns.pb(score); ll maxstreak=0LL; REP(i,0,turns.size()-1) { pl p1=turns[i]; pl p2 = turns[i+1]; if(p1.ff==p2.ff && p1.ss<=p1.ff && p2.ss>p2.ff) {maxstreak=max(maxstreak,p2.ss-p1.ss);} if(p1.ss==p2.ss && p1.ff<=p1.ss && p2.ff>p2.ss) {maxstreak=max(maxstreak,p2.ff-p1.ff);} } cout<<score.ff<<" "<<score.ss<<endl; cout<<ties<<endl; cout<<maxstreak+1LL<<endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 0 ms | 384 KB | Output is correct |