Submission #637819

# Submission time Handle Problem Language Result Execution time Memory
637819 2022-09-03T11:15:47 Z NotLinux Preokret (COCI18_preokret) C++14
50 / 50
1 ms 340 KB
/**
 * author: NotLinux
 * created: 03.09.2022 ~ 13:16:03
**/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#ifdef LOCAL
    #include "/home/notlinux/debug.h"
#else
    #define debug(x...) void(37)
#endif
void solve(){
      int a,b;cin >> a;
      vector < pair < int , int > > arr;
      for(int i = 0;i<a;i++){
        int num;cin >> num;
        arr.push_back({num,0});
      }
      cin >> b;
      for(int i = 0;i<b;i++){
        int num;cin >> num;
        arr.push_back({num,1});
      }
      sort(arr.begin(),arr.end());
    int ans1 = 0;
    int cnt1 = 0;
    int cnt0 = 0;
    int ans2 = 0;
    int bl1,bl2,bl3;
    debug(arr);
    for(auto itr : arr){
        if(itr.first <= 1440)ans1++;
        if(itr.second)cnt1++;
        else cnt0++;
        bl3 = bl2;
        bl2 = bl1;
        if(cnt1 == cnt0)bl1 = 0;
        else if(cnt1 < cnt0)bl1 = -1;
        else bl1 = 1;
        if((bl1 == 1 and bl3 == -1) or (bl1==-1 and bl3==1)){
            ans2++;
        }
    }
    cout << ans1 << endl;
    cout << ans2 << endl;
}
int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(nullptr);
    int tt=1;
    //cin >> tt;
    while(tt--)solve();
}

Compilation message

preokret.cpp: In function 'void solve()':
preokret.cpp:41:37: warning: 'bl2' may be used uninitialized in this function [-Wmaybe-uninitialized]
   41 |         if((bl1 == 1 and bl3 == -1) or (bl1==-1 and bl3==1)){
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 0 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 324 KB Output is correct
10 Correct 0 ms 316 KB Output is correct