#include <iostream>
using namespace std;
int main()
{
int N, K;
cin >> N >> K;
int A[N+1], B[N+1];
for(int i = 1; i <= N; i++) cin >> A[i] >> B[i];
for(int j = 1; j <= K; j++)
{
int T;
cin >> T;
for(int i = 1; i <= N; i++)
{
if(A[i] <= T) swap(A[i], B[i]);
}
}
long long res = 0;
for(int i = 1; i <= N; i++) res += A[i];
cout << res << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
3 ms |
204 KB |
Output is correct |
3 |
Correct |
5 ms |
324 KB |
Output is correct |
4 |
Correct |
5 ms |
332 KB |
Output is correct |
5 |
Correct |
5 ms |
204 KB |
Output is correct |
6 |
Correct |
5 ms |
204 KB |
Output is correct |
7 |
Correct |
5 ms |
328 KB |
Output is correct |
8 |
Correct |
3 ms |
204 KB |
Output is correct |
9 |
Correct |
3 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
204 KB |
Output is correct |
11 |
Correct |
5 ms |
204 KB |
Output is correct |
12 |
Correct |
4 ms |
204 KB |
Output is correct |
13 |
Correct |
6 ms |
320 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
3 ms |
204 KB |
Output is correct |
3 |
Correct |
5 ms |
324 KB |
Output is correct |
4 |
Correct |
5 ms |
332 KB |
Output is correct |
5 |
Correct |
5 ms |
204 KB |
Output is correct |
6 |
Correct |
5 ms |
204 KB |
Output is correct |
7 |
Correct |
5 ms |
328 KB |
Output is correct |
8 |
Correct |
3 ms |
204 KB |
Output is correct |
9 |
Correct |
3 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
204 KB |
Output is correct |
11 |
Correct |
5 ms |
204 KB |
Output is correct |
12 |
Correct |
4 ms |
204 KB |
Output is correct |
13 |
Correct |
6 ms |
320 KB |
Output is correct |
14 |
Correct |
366 ms |
600 KB |
Output is correct |
15 |
Correct |
1502 ms |
1004 KB |
Output is correct |
16 |
Execution timed out |
3073 ms |
1256 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
3 ms |
204 KB |
Output is correct |
3 |
Correct |
5 ms |
324 KB |
Output is correct |
4 |
Correct |
5 ms |
332 KB |
Output is correct |
5 |
Correct |
5 ms |
204 KB |
Output is correct |
6 |
Correct |
5 ms |
204 KB |
Output is correct |
7 |
Correct |
5 ms |
328 KB |
Output is correct |
8 |
Correct |
3 ms |
204 KB |
Output is correct |
9 |
Correct |
3 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
204 KB |
Output is correct |
11 |
Correct |
5 ms |
204 KB |
Output is correct |
12 |
Correct |
4 ms |
204 KB |
Output is correct |
13 |
Correct |
6 ms |
320 KB |
Output is correct |
14 |
Correct |
366 ms |
600 KB |
Output is correct |
15 |
Correct |
1502 ms |
1004 KB |
Output is correct |
16 |
Execution timed out |
3073 ms |
1256 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |