이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 ();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |