Submission #778088

# Submission time Handle Problem Language Result Execution time Memory
778088 2023-07-10T06:08:24 Z vjudge1 Preokret (COCI18_preokret) C++17
50 / 50
1 ms 340 KB
#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

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 time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 340 KB Output is correct