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>
#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
signed main(){
ios_base::sync_with_stdio();
cin.tie(0);cout.tie(0);
int n,m;
cin>>n>>m;
vector <int> c(m),cnt(n);
vector <vector <int> > a(2,vector <int> (n));
for(int i=0;i<n;i++)cin>>a[0][i]>>a[1][i];
for(int i=0;i<m;i++)cin>>c[i];
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
if(a[cnt[j]%2][j]<=c[i]){
cnt[j]++;
}
}
}
int ans=0;
for(int i=0;i<n;i++){
ans+=a[cnt[i]%2][i];
}
cout<<ans<<"\n";
}
/*
5 3
4 6
9 1
8 8
4 2
3 7
8
2
9
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |