제출 #1233720

#제출 시각아이디문제언어결과실행 시간메모리
1233720lopkus운세 보기 2 (JOI14_fortune_telling2)C++20
4 / 100
3096 ms1608 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++) { int pos = 0; for(int j = 1; j <= q; j++) { if(x[j] >= a[i] && x[j] < b[i]) { pos = j; } } if(pos != 0) { t[i] = 1; } pos += 1; for(int j = pos; j <= q; j++) { if(x[j] >= b[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...