#include<bits/stdc++.h>
using namespace std;
using lli = long long;
const int maxN = 2e5 + 5;
const int LG = 19;
int a[maxN],b[maxN],t[maxN];
int sp[LG][maxN],pre[maxN],suf[maxN];
int lg[maxN];
int n,k;
lli res;
void input()
{
cin >> n >> k;
for (int i = 1;i <= n;++i) cin >> a[i] >> b[i];
for (int i = 1;i <= k;++i) cin >> t[i];
}
void solve()
{
res = 0;
for (int i = 1;i <= n;++i)
{
for (int j = 1;j <= k;++j)
{
if (a[i] <= t[j]) swap(a[i],b[i]);
}
res += a[i];
}
cout << res;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
//freopen("P1.inp","r",stdin);
//freopen("P1.out","w",stdout);
input();
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
2 ms |
2384 KB |
Output is correct |
3 |
Correct |
3 ms |
2384 KB |
Output is correct |
4 |
Correct |
3 ms |
2384 KB |
Output is correct |
5 |
Correct |
3 ms |
2396 KB |
Output is correct |
6 |
Correct |
2 ms |
2384 KB |
Output is correct |
7 |
Correct |
2 ms |
2384 KB |
Output is correct |
8 |
Correct |
2 ms |
2384 KB |
Output is correct |
9 |
Correct |
2 ms |
2544 KB |
Output is correct |
10 |
Correct |
2 ms |
2384 KB |
Output is correct |
11 |
Correct |
2 ms |
2384 KB |
Output is correct |
12 |
Correct |
2 ms |
2384 KB |
Output is correct |
13 |
Correct |
2 ms |
2552 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
2 ms |
2384 KB |
Output is correct |
3 |
Correct |
3 ms |
2384 KB |
Output is correct |
4 |
Correct |
3 ms |
2384 KB |
Output is correct |
5 |
Correct |
3 ms |
2396 KB |
Output is correct |
6 |
Correct |
2 ms |
2384 KB |
Output is correct |
7 |
Correct |
2 ms |
2384 KB |
Output is correct |
8 |
Correct |
2 ms |
2384 KB |
Output is correct |
9 |
Correct |
2 ms |
2544 KB |
Output is correct |
10 |
Correct |
2 ms |
2384 KB |
Output is correct |
11 |
Correct |
2 ms |
2384 KB |
Output is correct |
12 |
Correct |
2 ms |
2384 KB |
Output is correct |
13 |
Correct |
2 ms |
2552 KB |
Output is correct |
14 |
Correct |
247 ms |
2640 KB |
Output is correct |
15 |
Correct |
999 ms |
3152 KB |
Output is correct |
16 |
Correct |
2159 ms |
3496 KB |
Output is correct |
17 |
Execution timed out |
3048 ms |
3664 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
2 ms |
2384 KB |
Output is correct |
3 |
Correct |
3 ms |
2384 KB |
Output is correct |
4 |
Correct |
3 ms |
2384 KB |
Output is correct |
5 |
Correct |
3 ms |
2396 KB |
Output is correct |
6 |
Correct |
2 ms |
2384 KB |
Output is correct |
7 |
Correct |
2 ms |
2384 KB |
Output is correct |
8 |
Correct |
2 ms |
2384 KB |
Output is correct |
9 |
Correct |
2 ms |
2544 KB |
Output is correct |
10 |
Correct |
2 ms |
2384 KB |
Output is correct |
11 |
Correct |
2 ms |
2384 KB |
Output is correct |
12 |
Correct |
2 ms |
2384 KB |
Output is correct |
13 |
Correct |
2 ms |
2552 KB |
Output is correct |
14 |
Correct |
247 ms |
2640 KB |
Output is correct |
15 |
Correct |
999 ms |
3152 KB |
Output is correct |
16 |
Correct |
2159 ms |
3496 KB |
Output is correct |
17 |
Execution timed out |
3048 ms |
3664 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |