Submission #48391

#TimeUsernameProblemLanguageResultExecution timeMemory
48391maksim_gaponovFortune Telling 2 (JOI14_fortune_telling2)C++14
4 / 100
7 ms1540 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; void openFiles() { #ifdef KEK assert(freopen("input.txt", "r", stdin)); assert(freopen("output.txt", "w", stdout)); #endif } void IOoptimize() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } const int MAXN = 1e3 + 10; const int MAXK = 1e3 + 10; int a[MAXN][2]; int t[MAXK]; int active_side[MAXN]; int main() { openFiles(); IOoptimize(); int n, k; cin >> n >> k; for (int i = 0; i < n; i++) { cin >> a[i][0] >> a[i][1]; } for (int i = 0; i < k; i++) { cin >> t[i]; } for (int i = 0; i < k; i++) { for (int j = 0; j < n; j++) { if (a[j][active_side[j]] <= t[i]) { active_side[j] = 1 - active_side[j]; } } } ll sum = 0; for (int i = 0; i < n; i++) { sum += a[i][active_side[i]]; } cout << sum; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...