Submission #171271

#TimeUsernameProblemLanguageResultExecution timeMemory
171271AdilPreokret (COCI18_preokret)C++14
50 / 50
8 ms504 KiB
#include <bits/stdc++.h> using namespace std; int n, m, a[3000], dp[3000], ans; int main(){ cin >> n; for(int i = 1; i <= n; i++){ int l; cin >> l; a[l] = 1; } cin >> m; for(int i = 1; i <= m; i++){ int l; cin >> l; a[l] = 2; } int k1 = 0, k2 = 0; for(int i = 1; i <= 2880; i++){ if(a[i] == 1){ k1++; } if(a[i] == 2){ k2++; } if(k1 == k2){ dp[i] = dp[i - 1]; } else if(k1 < k2){ dp[i] = 2; } else{ dp[i] = 1; } if(i == 1440){ cout << k1 + k2 << "\n"; } if((dp[i] == 1 && dp[i - 1] == 2) || (dp[i] == 2 && dp[i - 1] == 1)){ ans++; } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...