Submission #496000

#TimeUsernameProblemLanguageResultExecution timeMemory
496000NimbostratusPreokret (COCI19_preokret)C++17
50 / 50
1 ms204 KiB
#include "bits/stdc++.h" #define endl '\n' #define fi first #define se second constexpr int maxn = 2e5 + 5; constexpr int inf = 2e9; constexpr int mod = 1e9 + 7; using namespace std; using lint = long long; using pii = pair<int, int>; int n; int a[maxn]; int g1, g2, d, turn; int pre[maxn]; bool w1; signed main() { #ifdef Local freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]; d = 1; for(int i = 1; i <= n; i++) { g1 += a[i] == 1; g2 += a[i] == 2; pre[i] = pre[i - 1]; pre[i] += a[i] == 1 ? 1 : -1; d += g1 == g2; } for(int i = 1; i <= n; i++) for(int j = i; j <= n; j++) { if(pre[i] <= 0 && pre[j] <= 0 || pre[i] >= 0 && pre[j] >= 0) continue; int cur = j - i; int x = pre[i] > pre[j] ? -1 : 1; for(int k = i; k < j; k++) if(pre[k + 1] - pre[k] != x) cur = 0; turn = max(turn, cur); } cout << g1 << " " << g2 << endl; cout << d << endl; cout << turn << endl; }

Compilation message (stderr)

preokret.cpp: In function 'int main()':
preokret.cpp:38:19: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   38 |    if(pre[i] <= 0 && pre[j] <= 0 || pre[i] >= 0 && pre[j] >= 0)
      |       ~~~~~~~~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...