Submission #811139

#TimeUsernameProblemLanguageResultExecution timeMemory
811139pccPreokret (COCI19_preokret)C++14
50 / 50
1 ms328 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll,ll> #define pii pair<int,int> #define fs first #define sc second int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); int n; cin>>n; pii score = {0,0}; int ties = 1; vector<int> v(n); for(auto &i:v){ cin>>i; if(i == 1)score.fs++; else score.sc++; if(score.fs == score.sc)ties++; } vector<pii> vv; for(auto &i:v){ if(vv.empty()||vv.back().fs != i)vv.push_back({i,1}); else vv.back().sc++; } score = {0,0}; int turn = 0; for(auto &i:vv){ if(i.fs == 1&&score.fs<score.sc&&score.fs+i.sc>score.sc){ turn = max(turn,i.sc); } else if(i.fs == 2&&score.sc<score.fs&&score.sc+i.sc>score.fs){ turn = max(turn,i.sc); } if(i.fs == 1)score.fs += i.sc; else score.sc += i.sc; } cout<<score.fs<<' '<<score.sc<<'\n'<<ties<<'\n'<<turn; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...