This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |