#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, k; cin >> n >> k;
vector<ll> A(n), B(n);
vector<ll> T(k);
for(int i = 0; i < n; i++) cin >> A[i] >> B[i];
for(int i = 0; i < k; i++) cin >> T[i];
ll ans = 0;
for(int i = 0; i < n; i++){
for(int j = 0; j < k; j++){
if(T[j] >= A[i]) swap(A[i], B[i]);
}
ans+=A[i];
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
332 KB |
Output is correct |
3 |
Correct |
5 ms |
380 KB |
Output is correct |
4 |
Correct |
5 ms |
328 KB |
Output is correct |
5 |
Correct |
5 ms |
328 KB |
Output is correct |
6 |
Correct |
6 ms |
340 KB |
Output is correct |
7 |
Correct |
5 ms |
336 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
2 ms |
340 KB |
Output is correct |
10 |
Correct |
5 ms |
340 KB |
Output is correct |
11 |
Correct |
5 ms |
340 KB |
Output is correct |
12 |
Correct |
5 ms |
340 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
332 KB |
Output is correct |
3 |
Correct |
5 ms |
380 KB |
Output is correct |
4 |
Correct |
5 ms |
328 KB |
Output is correct |
5 |
Correct |
5 ms |
328 KB |
Output is correct |
6 |
Correct |
6 ms |
340 KB |
Output is correct |
7 |
Correct |
5 ms |
336 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
2 ms |
340 KB |
Output is correct |
10 |
Correct |
5 ms |
340 KB |
Output is correct |
11 |
Correct |
5 ms |
340 KB |
Output is correct |
12 |
Correct |
5 ms |
340 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
364 ms |
832 KB |
Output is correct |
15 |
Correct |
1963 ms |
1368 KB |
Output is correct |
16 |
Execution timed out |
3067 ms |
1876 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
332 KB |
Output is correct |
3 |
Correct |
5 ms |
380 KB |
Output is correct |
4 |
Correct |
5 ms |
328 KB |
Output is correct |
5 |
Correct |
5 ms |
328 KB |
Output is correct |
6 |
Correct |
6 ms |
340 KB |
Output is correct |
7 |
Correct |
5 ms |
336 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
2 ms |
340 KB |
Output is correct |
10 |
Correct |
5 ms |
340 KB |
Output is correct |
11 |
Correct |
5 ms |
340 KB |
Output is correct |
12 |
Correct |
5 ms |
340 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
364 ms |
832 KB |
Output is correct |
15 |
Correct |
1963 ms |
1368 KB |
Output is correct |
16 |
Execution timed out |
3067 ms |
1876 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |