#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
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
3 ms |
348 KB |
Output is correct |
3 |
Correct |
5 ms |
504 KB |
Output is correct |
4 |
Correct |
5 ms |
348 KB |
Output is correct |
5 |
Correct |
5 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
448 KB |
Output is correct |
7 |
Correct |
5 ms |
508 KB |
Output is correct |
8 |
Correct |
3 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
604 KB |
Output is correct |
11 |
Correct |
4 ms |
508 KB |
Output is correct |
12 |
Correct |
4 ms |
348 KB |
Output is correct |
13 |
Correct |
7 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
3 ms |
348 KB |
Output is correct |
3 |
Correct |
5 ms |
504 KB |
Output is correct |
4 |
Correct |
5 ms |
348 KB |
Output is correct |
5 |
Correct |
5 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
448 KB |
Output is correct |
7 |
Correct |
5 ms |
508 KB |
Output is correct |
8 |
Correct |
3 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
604 KB |
Output is correct |
11 |
Correct |
4 ms |
508 KB |
Output is correct |
12 |
Correct |
4 ms |
348 KB |
Output is correct |
13 |
Correct |
7 ms |
344 KB |
Output is correct |
14 |
Correct |
431 ms |
1108 KB |
Output is correct |
15 |
Correct |
1700 ms |
1640 KB |
Output is correct |
16 |
Execution timed out |
3024 ms |
2156 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
3 ms |
348 KB |
Output is correct |
3 |
Correct |
5 ms |
504 KB |
Output is correct |
4 |
Correct |
5 ms |
348 KB |
Output is correct |
5 |
Correct |
5 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
448 KB |
Output is correct |
7 |
Correct |
5 ms |
508 KB |
Output is correct |
8 |
Correct |
3 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
604 KB |
Output is correct |
11 |
Correct |
4 ms |
508 KB |
Output is correct |
12 |
Correct |
4 ms |
348 KB |
Output is correct |
13 |
Correct |
7 ms |
344 KB |
Output is correct |
14 |
Correct |
431 ms |
1108 KB |
Output is correct |
15 |
Correct |
1700 ms |
1640 KB |
Output is correct |
16 |
Execution timed out |
3024 ms |
2156 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |