This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<long long, long long>
#define fr first
#define se second
const int MAXN = 1e5 + 10;
int v[MAXN];
int32_t main() {
int n, k;
cin >> n >> k;
vector<pii> c(n);
for (int i = 0; i < n; i++) {
cin >> c[i].fr >> c[i].se;
}
for (int i = 1; i <= k; i++) {
cin >> v[i];
}
int ans = 0;
for (int i = 0; i < n; i++) {
bool curr = 0;
for (int j = 1; j <= k; j++) {
if (!curr) {
if (c[i].fr <= v[j]) {
curr = 1;
}
} else {
if (c[i].se <= v[j]) {
curr = 0;
}
}
}
if (curr) ans += c[i].se;
else ans += c[i].fr;
}
cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |