#include <iostream>
#include<bits/stdc++.h>
using namespace std;
long long a[100002];
long long b[100002];
long long v[100002];
int main()
{
ios_base::sync_with_stdio(false);
int n,k;
cin >> n >> k;
for(int i =0;i<n;i++){
long long f,g;
cin >> f >> g;
a[i] = f;
b[i] = g;
v[i] = a[i];
}
for(int i =0;i<k;i++) {
long long t;
cin >> t;
for(int j=0;j<n;j++){
if(t >= v[j]) {
if(v[j] == a[j]) v[j] = b[j];
else v[j] = a[j];
}
}
}
long long sum = 0;
for(int i =0;i<n;i++){
sum+=v[i];
}
cout << sum << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
6 ms |
376 KB |
Output is correct |
3 |
Correct |
8 ms |
432 KB |
Output is correct |
4 |
Correct |
9 ms |
560 KB |
Output is correct |
5 |
Correct |
9 ms |
560 KB |
Output is correct |
6 |
Correct |
10 ms |
560 KB |
Output is correct |
7 |
Correct |
10 ms |
564 KB |
Output is correct |
8 |
Correct |
5 ms |
564 KB |
Output is correct |
9 |
Correct |
4 ms |
640 KB |
Output is correct |
10 |
Correct |
4 ms |
640 KB |
Output is correct |
11 |
Correct |
10 ms |
640 KB |
Output is correct |
12 |
Correct |
10 ms |
640 KB |
Output is correct |
13 |
Correct |
9 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
6 ms |
376 KB |
Output is correct |
3 |
Correct |
8 ms |
432 KB |
Output is correct |
4 |
Correct |
9 ms |
560 KB |
Output is correct |
5 |
Correct |
9 ms |
560 KB |
Output is correct |
6 |
Correct |
10 ms |
560 KB |
Output is correct |
7 |
Correct |
10 ms |
564 KB |
Output is correct |
8 |
Correct |
5 ms |
564 KB |
Output is correct |
9 |
Correct |
4 ms |
640 KB |
Output is correct |
10 |
Correct |
4 ms |
640 KB |
Output is correct |
11 |
Correct |
10 ms |
640 KB |
Output is correct |
12 |
Correct |
10 ms |
640 KB |
Output is correct |
13 |
Correct |
9 ms |
640 KB |
Output is correct |
14 |
Correct |
584 ms |
876 KB |
Output is correct |
15 |
Correct |
2281 ms |
1108 KB |
Output is correct |
16 |
Execution timed out |
3014 ms |
1260 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
6 ms |
376 KB |
Output is correct |
3 |
Correct |
8 ms |
432 KB |
Output is correct |
4 |
Correct |
9 ms |
560 KB |
Output is correct |
5 |
Correct |
9 ms |
560 KB |
Output is correct |
6 |
Correct |
10 ms |
560 KB |
Output is correct |
7 |
Correct |
10 ms |
564 KB |
Output is correct |
8 |
Correct |
5 ms |
564 KB |
Output is correct |
9 |
Correct |
4 ms |
640 KB |
Output is correct |
10 |
Correct |
4 ms |
640 KB |
Output is correct |
11 |
Correct |
10 ms |
640 KB |
Output is correct |
12 |
Correct |
10 ms |
640 KB |
Output is correct |
13 |
Correct |
9 ms |
640 KB |
Output is correct |
14 |
Correct |
584 ms |
876 KB |
Output is correct |
15 |
Correct |
2281 ms |
1108 KB |
Output is correct |
16 |
Execution timed out |
3014 ms |
1260 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |