#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
int n, k;
cin >> n >> k;
ll a[n], b[n];
for(int i=0; i<n; i++)
cin >> a[i] >> b[i];
while(k--)
{
ll x;
cin >> x;
for(int i=0; i<n; i++)
if(a[i] <= x)
swap(a[i], b[i]);
}
ll sum = 0;
for(int i=0; i<n; i++)
sum += a[i];
cout << sum << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
484 KB |
Output is correct |
3 |
Correct |
10 ms |
484 KB |
Output is correct |
4 |
Correct |
9 ms |
576 KB |
Output is correct |
5 |
Correct |
9 ms |
576 KB |
Output is correct |
6 |
Correct |
7 ms |
584 KB |
Output is correct |
7 |
Correct |
9 ms |
584 KB |
Output is correct |
8 |
Correct |
5 ms |
584 KB |
Output is correct |
9 |
Correct |
4 ms |
584 KB |
Output is correct |
10 |
Correct |
6 ms |
584 KB |
Output is correct |
11 |
Correct |
9 ms |
584 KB |
Output is correct |
12 |
Correct |
7 ms |
584 KB |
Output is correct |
13 |
Correct |
8 ms |
616 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
484 KB |
Output is correct |
3 |
Correct |
10 ms |
484 KB |
Output is correct |
4 |
Correct |
9 ms |
576 KB |
Output is correct |
5 |
Correct |
9 ms |
576 KB |
Output is correct |
6 |
Correct |
7 ms |
584 KB |
Output is correct |
7 |
Correct |
9 ms |
584 KB |
Output is correct |
8 |
Correct |
5 ms |
584 KB |
Output is correct |
9 |
Correct |
4 ms |
584 KB |
Output is correct |
10 |
Correct |
6 ms |
584 KB |
Output is correct |
11 |
Correct |
9 ms |
584 KB |
Output is correct |
12 |
Correct |
7 ms |
584 KB |
Output is correct |
13 |
Correct |
8 ms |
616 KB |
Output is correct |
14 |
Correct |
411 ms |
756 KB |
Output is correct |
15 |
Correct |
1670 ms |
916 KB |
Output is correct |
16 |
Execution timed out |
3045 ms |
1004 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
484 KB |
Output is correct |
3 |
Correct |
10 ms |
484 KB |
Output is correct |
4 |
Correct |
9 ms |
576 KB |
Output is correct |
5 |
Correct |
9 ms |
576 KB |
Output is correct |
6 |
Correct |
7 ms |
584 KB |
Output is correct |
7 |
Correct |
9 ms |
584 KB |
Output is correct |
8 |
Correct |
5 ms |
584 KB |
Output is correct |
9 |
Correct |
4 ms |
584 KB |
Output is correct |
10 |
Correct |
6 ms |
584 KB |
Output is correct |
11 |
Correct |
9 ms |
584 KB |
Output is correct |
12 |
Correct |
7 ms |
584 KB |
Output is correct |
13 |
Correct |
8 ms |
616 KB |
Output is correct |
14 |
Correct |
411 ms |
756 KB |
Output is correct |
15 |
Correct |
1670 ms |
916 KB |
Output is correct |
16 |
Execution timed out |
3045 ms |
1004 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |