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;
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |