이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |