#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 j=0;j<n;j++){
if(cards[j][table[j]]<=t){
if(table[j]==1){
table[j]=0;
}else if(table[j]==0){
table[j]=1;
}
}
}
}
ll sum=0;
for(ll i=0;i<n;i++){
sum+=cards[i][table[i]];
}
cout<<sum<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
6492 KB |
Output is correct |
2 |
Correct |
5 ms |
6748 KB |
Output is correct |
3 |
Correct |
8 ms |
6612 KB |
Output is correct |
4 |
Correct |
7 ms |
6744 KB |
Output is correct |
5 |
Correct |
7 ms |
6772 KB |
Output is correct |
6 |
Correct |
6 ms |
6720 KB |
Output is correct |
7 |
Correct |
7 ms |
6748 KB |
Output is correct |
8 |
Correct |
5 ms |
6772 KB |
Output is correct |
9 |
Correct |
4 ms |
6748 KB |
Output is correct |
10 |
Correct |
5 ms |
6748 KB |
Output is correct |
11 |
Correct |
7 ms |
6748 KB |
Output is correct |
12 |
Correct |
7 ms |
6748 KB |
Output is correct |
13 |
Correct |
8 ms |
6748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
6492 KB |
Output is correct |
2 |
Correct |
5 ms |
6748 KB |
Output is correct |
3 |
Correct |
8 ms |
6612 KB |
Output is correct |
4 |
Correct |
7 ms |
6744 KB |
Output is correct |
5 |
Correct |
7 ms |
6772 KB |
Output is correct |
6 |
Correct |
6 ms |
6720 KB |
Output is correct |
7 |
Correct |
7 ms |
6748 KB |
Output is correct |
8 |
Correct |
5 ms |
6772 KB |
Output is correct |
9 |
Correct |
4 ms |
6748 KB |
Output is correct |
10 |
Correct |
5 ms |
6748 KB |
Output is correct |
11 |
Correct |
7 ms |
6748 KB |
Output is correct |
12 |
Correct |
7 ms |
6748 KB |
Output is correct |
13 |
Correct |
8 ms |
6748 KB |
Output is correct |
14 |
Correct |
459 ms |
7260 KB |
Output is correct |
15 |
Correct |
1829 ms |
7896 KB |
Output is correct |
16 |
Execution timed out |
3024 ms |
8108 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
6492 KB |
Output is correct |
2 |
Correct |
5 ms |
6748 KB |
Output is correct |
3 |
Correct |
8 ms |
6612 KB |
Output is correct |
4 |
Correct |
7 ms |
6744 KB |
Output is correct |
5 |
Correct |
7 ms |
6772 KB |
Output is correct |
6 |
Correct |
6 ms |
6720 KB |
Output is correct |
7 |
Correct |
7 ms |
6748 KB |
Output is correct |
8 |
Correct |
5 ms |
6772 KB |
Output is correct |
9 |
Correct |
4 ms |
6748 KB |
Output is correct |
10 |
Correct |
5 ms |
6748 KB |
Output is correct |
11 |
Correct |
7 ms |
6748 KB |
Output is correct |
12 |
Correct |
7 ms |
6748 KB |
Output is correct |
13 |
Correct |
8 ms |
6748 KB |
Output is correct |
14 |
Correct |
459 ms |
7260 KB |
Output is correct |
15 |
Correct |
1829 ms |
7896 KB |
Output is correct |
16 |
Execution timed out |
3024 ms |
8108 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |