# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
748260 | 2023-05-26T02:11:02 Z | Trunkty | Preokret (COCI19_preokret) | C++14 | 1 ms | 332 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define int ll int n,a,b,istie=1,turn; int arr[255]; vector<int> event; signed main(){ ios::sync_with_stdio(false); cin.tie(NULL); cin >> n; int curr=0,pos=1; for(int i=1;i<=n;i++){ cin >> arr[i]; if(arr[i]==pos){ curr++; } else{ event.push_back(curr); curr = 1; pos = arr[i]; } } event.push_back(curr); for(int i=0;i<event.size();i++){ if(event[i]==0){ continue; } if(i%2){ if(b<a and b+event[i]>a){ turn = max(turn,event[i]); } if(b<a and b+event[i]>=a){ istie++; } b += event[i]; } else{ if(a<b and a+event[i]>b){ turn = max(turn,event[i]); } if(a<b and a+event[i]>=b){ istie++; } a += event[i]; } } cout << a << " " << b << "\n"; cout << istie << "\n"; cout << turn << "\n"; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 324 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 324 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 324 KB | Output is correct |
7 | Correct | 0 ms | 328 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 332 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |