#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define endl '\n'
#define pb push_back
#define mk make_pair
#define sz size()
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define kill(x) return cout << x << endl, void();
#define int ll
#define pii pair <int, int>
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC target ("avx2")
const int N = 1e6 + 5;
const int MOD = 998244353, INF = 2e9, sq = 300;
int a[2][N], c[N];
void Solve ()
{
int n, k;
cin >> n >> k;
if (n > 40000 || k > 40000)
return;
for (int i = 0; i < n; i++)
cin >> a[0][i] >> a[1][i];
for (int i = 0; i < k; i++)
cin >> c[i];
int ans = 0;
for (int i = 0; i < n; i++)
{
int wef = 0;
for (int j = 0; j < k; j++)
if (c[j] >= a[wef][i])
wef = 1 - wef;
ans += a[wef][i];
}
cout << ans << endl;
}
int32_t main ()
{
ios::sync_with_stdio (0), cin.tie (0), cout.tie (0);
int tt = 1;
// cin >> tt;
while (tt--)
Solve ();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
3 ms |
404 KB |
Output is correct |
5 |
Correct |
3 ms |
388 KB |
Output is correct |
6 |
Correct |
3 ms |
340 KB |
Output is correct |
7 |
Correct |
3 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
2 ms |
340 KB |
Output is correct |
10 |
Correct |
3 ms |
388 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
344 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
3 ms |
404 KB |
Output is correct |
5 |
Correct |
3 ms |
388 KB |
Output is correct |
6 |
Correct |
3 ms |
340 KB |
Output is correct |
7 |
Correct |
3 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
2 ms |
340 KB |
Output is correct |
10 |
Correct |
3 ms |
388 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
344 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
297 ms |
860 KB |
Output is correct |
15 |
Correct |
1174 ms |
1376 KB |
Output is correct |
16 |
Correct |
2583 ms |
1912 KB |
Output is correct |
17 |
Execution timed out |
3065 ms |
2380 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
3 ms |
404 KB |
Output is correct |
5 |
Correct |
3 ms |
388 KB |
Output is correct |
6 |
Correct |
3 ms |
340 KB |
Output is correct |
7 |
Correct |
3 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
2 ms |
340 KB |
Output is correct |
10 |
Correct |
3 ms |
388 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
344 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
297 ms |
860 KB |
Output is correct |
15 |
Correct |
1174 ms |
1376 KB |
Output is correct |
16 |
Correct |
2583 ms |
1912 KB |
Output is correct |
17 |
Execution timed out |
3065 ms |
2380 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |