제출 #499075

#제출 시각아이디문제언어결과실행 시간메모리
499075600Mihnea운세 보기 2 (JOI14_fortune_telling2)C++17
4 / 100
3038 ms1868 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const int N = 200000 + 7; int n; int q; int a[N]; int b[N]; int t[N]; signed main() { ios::sync_with_stdio(0); cin.tie(0); /// freopen ("input", "r", stdin); cin >> n >> q; for (int i = 1; i <= n; i++) { cin >> a[i] >> b[i]; } for (int iq = 1; iq <= q; iq++) { cin >> t[iq]; } ll sol = 0; for (int i = 1; i <= n; i++) { int mn = min(a[i], b[i]); int mx = max(a[i], b[i]); int start = 1, current = a[i]; for (int j = 1; j <= q; j++) { if (mn <= t[j] && t[j] < mx) { start = j + 1; current = mx; } } int cnt = 0; for (int j = start; j <= q; j++) { cnt += (mx <= t[j]); } if (cnt % 2 == 0) { sol += current; } else { sol += a[i] + b[i] - current; } } cout << sol << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...