Submission #866412

#TimeUsernameProblemLanguageResultExecution timeMemory
866412vjudge1Preokret (COCI19_preokret)C++17
50 / 50
1 ms456 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #define sp << " " << #define int long long #define vi vector<int> #define pb push_back #define F(xxx,yyy) for (int xxx=1;xxx<=yyy;xxx++) #define pii pair<int,int> #define ordered_set tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> const int N = 3e5+1; const int MOD = 1e9+7; void solve() { int n; cin >> n; int a = 0,b=0; int tie = 1; vi x(n+1); F(i,n) { cin >> x[i]; if (x[i] == 1) a++; else b++; if (a == b) tie++; } cout << a sp b << endl; cout << tie << endl; int ans = 0; a = b = 0; for (int i=1;i<=n;i++) { int c = 0,d=0; for (int j=i;j<=n;j++) { if (x[j] == 1) c++; else break; } for (int j=i;j<=n;j++) { if (x[j] == 2) d++; else break; } if (a < b && a+c > b) ans = max(ans,c); if (b < a && b+d > a) ans = max(ans,d); if (x[i] == 1) a++; else b++; } cout << ans << endl; } signed main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int t = 1; //cin >> t; F(i,t) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...