Submission #748260

#TimeUsernameProblemLanguageResultExecution timeMemory
748260TrunktyPreokret (COCI19_preokret)C++14
50 / 50
1 ms332 KiB
#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 (stderr)

preokret.cpp: In function 'int main()':
preokret.cpp:27:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i=0;i<event.size();i++){
      |                 ~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...