Submission #1233718

#TimeUsernameProblemLanguageResultExecution timeMemory
1233718lopkusFortune Telling 2 (JOI14_fortune_telling2)C++20
4 / 100
3094 ms1348 KiB
#include <bits/stdc++.h> #define int int64_t signed main() { int n, q; std::cin >> n >> q; std::vector<int> a(n + 1), b(n + 1); for(int i = 1; i <= n; i++) { std::cin >> a[i] >> b[i]; } std::vector<int> x(q + 1); for(int i = 1; i <= q; i++) { std::cin >> x[i]; } std::vector<int> t(n + 1); for(int i = 1; i <= n; i++) { if(a[i] > b[i]) { t[i] = 1; std::swap(a[i], b[i]); } } for(int i = 1; i <= n; i++) { for(int j = 1; j <= q; j++) { if(x[j] >= b[i]) { t[i] ^= 1; } else if(x[j] >= a[i]) { t[i] = 1; } } } int ans = 0; for(int i = 1; i <= n; i++) { ans += (t[i] == 0 ? a[i] : b[i]); } std::cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...