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