Submission #96701

#TimeUsernameProblemLanguageResultExecution timeMemory
96701nandonathanielPreokret (COCI18_preokret)C++14
50 / 50
3 ms376 KiB
#include<bits/stdc++.h> using namespace std; typedef pair<int,int> pii; int preA[6005],preB[6005],kode[6005]; int main(){ vector<pii> V; int a,b,x,ans1=0; cin >> a; for(int i=0;i<a;i++){ cin >> x; V.push_back(make_pair(x,0)); if(x<=1440)ans1++; } cin >> b; for(int i=0;i<b;i++){ cin >> x; V.push_back(make_pair(x,1)); if(x<=1440)ans1++; } sort(V.begin(),V.end()); for(int i=0;i<V.size();i++){ if(i==0){ if(V[i].second==0){ preA[i]=1; preB[i]=0; } if(V[i].second==1){ preB[i]=1; preA[i]=0; } } else{ if(V[i].second==0){ preA[i]=preA[i-1]+1; preB[i]=preB[i-1]; } if(V[i].second==1){ preB[i]=preB[i-1]+1; preA[i]=preA[i-1]; } } } for(int i=0;i<V.size();i++){ if(preA[i]>preB[i])kode[i]=0; if(preB[i]>preA[i])kode[i]=1; if(preA[i]==preB[i])kode[i]=kode[i-1]; } int ans2=0; for(int i=1;i<V.size();i++){ if(kode[i]!=kode[i-1])ans2++; } cout << ans1 << "\n"; cout << ans2 << "\n"; return 0; }

Compilation message (stderr)

preokret.cpp: In function 'int main()':
preokret.cpp:23:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<V.size();i++){
              ~^~~~~~~~~
preokret.cpp:45:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<V.size();i++){
              ~^~~~~~~~~
preokret.cpp:51:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=1;i<V.size();i++){
              ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...