// __builtin_popcount(x)
// __builtin_popcountll(x)
#define here cerr<<"===========================================\n"
#include <bits/stdc++.h>
#define ld double
#define ll long long
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
using namespace std;
#define maxn 200005
ll n,k;
ll a[maxn];
ll b[maxn];
ll c[maxn];
ll d[maxn];
int main(){
ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);
cin >> n >> k;
for(ll i = 1;i<=n;i++) cin >> a[i] >> b[i];
for(ll i = 1;i<=k;i++) cin >> c[i];
for(ll i = 1;i<=n;i++) d[i] = a[i];
for(ll i = 1;i<=k;i++){
for(ll j = 1;j<=n;j++){
if(c[i]>=d[j]){
if(d[j]==a[j]) d[j] = b[j];
else d[j] = a[j];
}
}
}
ll ans = 0;
for(ll i = 1;i<=n;i++)ans+=d[i];
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
4 ms |
332 KB |
Output is correct |
3 |
Correct |
5 ms |
344 KB |
Output is correct |
4 |
Correct |
6 ms |
472 KB |
Output is correct |
5 |
Correct |
5 ms |
340 KB |
Output is correct |
6 |
Correct |
5 ms |
340 KB |
Output is correct |
7 |
Correct |
6 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
404 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
6 ms |
340 KB |
Output is correct |
12 |
Correct |
5 ms |
340 KB |
Output is correct |
13 |
Correct |
6 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
4 ms |
332 KB |
Output is correct |
3 |
Correct |
5 ms |
344 KB |
Output is correct |
4 |
Correct |
6 ms |
472 KB |
Output is correct |
5 |
Correct |
5 ms |
340 KB |
Output is correct |
6 |
Correct |
5 ms |
340 KB |
Output is correct |
7 |
Correct |
6 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
404 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
6 ms |
340 KB |
Output is correct |
12 |
Correct |
5 ms |
340 KB |
Output is correct |
13 |
Correct |
6 ms |
340 KB |
Output is correct |
14 |
Correct |
467 ms |
928 KB |
Output is correct |
15 |
Correct |
1854 ms |
1536 KB |
Output is correct |
16 |
Execution timed out |
3038 ms |
2132 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
4 ms |
332 KB |
Output is correct |
3 |
Correct |
5 ms |
344 KB |
Output is correct |
4 |
Correct |
6 ms |
472 KB |
Output is correct |
5 |
Correct |
5 ms |
340 KB |
Output is correct |
6 |
Correct |
5 ms |
340 KB |
Output is correct |
7 |
Correct |
6 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
404 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
6 ms |
340 KB |
Output is correct |
12 |
Correct |
5 ms |
340 KB |
Output is correct |
13 |
Correct |
6 ms |
340 KB |
Output is correct |
14 |
Correct |
467 ms |
928 KB |
Output is correct |
15 |
Correct |
1854 ms |
1536 KB |
Output is correct |
16 |
Execution timed out |
3038 ms |
2132 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |