Submission #778088

#TimeUsernameProblemLanguageResultExecution timeMemory
778088vjudge1Preokret (COCI18_preokret)C++17
50 / 50
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define faster ios_base::sync_with_stdio(false);cin.tie(NULL); #define OYY 1000000005 #define mod 998244353 int cev=0,da[3000],ba[3000],mp[3000]; int32_t main(){ faster int a;cin>>a; for(int i=1;i<=a;i++){ cin>>da[i]; if(da[i]<=1440){ cev++; } mp[da[i]]++; } int b;cin>>b; for(int i=1;i<=b;i++) { cin>>ba[i]; if(ba[i]<=1440){ cev++; } mp[ba[i]]--; } cout<<cev<<'\n'; int ger=0; cev=0; for(int i=1;i<=3000;i++){ mp[i]+=mp[i-1]; if(ger==0){ if(mp[i]>0){ ger=1; } else if(mp[i]<0){ ger=2; } } else if(ger==2 && mp[i]>0){ cev++; ger=1; } else if(ger==1 && mp[i]<0){ cev++; ger=2; } } cout<<cev<<'\n'; return 0; }

Compilation message (stderr)

preokret.cpp: In function 'int32_t main()':
preokret.cpp:31:14: warning: iteration 2999 invokes undefined behavior [-Waggressive-loop-optimizations]
   31 |         mp[i]+=mp[i-1];
      |         ~~~~~^~~~~~~~~
preokret.cpp:30:18: note: within this loop
   30 |     for(int i=1;i<=3000;i++){
      |                 ~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...