Submission #637819

#TimeUsernameProblemLanguageResultExecution timeMemory
637819NotLinuxPreokret (COCI18_preokret)C++14
50 / 50
1 ms340 KiB
/** * 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 (stderr)

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 timeMemoryGrader output
Fetching results...