제출 #1332452

#제출 시각아이디문제언어결과실행 시간메모리
1332452rana_azkaFortune Telling 2 (JOI14_fortune_telling2)C++20
4 / 100
3093 ms1092 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
const int MAXN = 2e5;

int n, m;
int arr[5][MAXN+5];
bool stat[MAXN+5];

void solve(){
    cin >> n >> m;
    for(int i = 1; i <= n; i++) cin >> arr[0][i] >> arr[1][i];

    while(m--){
        int t; cin >> t;

        for(int i = 1; i <= n; i++){
            if(arr[stat[i]][i] <= t) stat[i] ^= 1;
        }
    }

    int ans = 0;
    for(int i = 1; i <= n; i++) ans += arr[stat[i]][i];

    cout << ans << endl;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int tc = 1;
    // cin >> tc;
    while(tc--){
        solve();
    }

    return 0;
}

/*
5 3
4 6
9 1
8 8
4 2
3 7
8
2
9
=> 18
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...