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;
#define ll long long
#define pb push_back
#define ff first
#define ss second
const int N=200000;
ll n,k;
vector<vector<ll>>cards(N+10);
vector<ll>table(N+10);
int main(){
cin >> n >> k;
for(ll i=0;i<n;i++){
ll a,b; cin>>a>>b;
cards[i]={a,b};
table[i]=0;
}
for(ll i=0;i<k;i++){
ll t; cin >> t;
for(ll i=0;i<n;i++){
if(cards[i][table[i]]<=t){
if(table[i]==1){
table[i]=0;
}else if(table[i]==0){
table[i]=1;
}
}
}
}
ll sum=0;
for(ll i=0;i<n;i++){
sum+=cards[i][table[i]];
}
cout<<sum<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |