Submission #1304701

#TimeUsernameProblemLanguageResultExecution timeMemory
1304701quollcucumber`Fortune Telling 2 (JOI14_fortune_telling2)C++20
4 / 100
3094 ms876 KiB
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int n, k;
    cin >> n >> k;
    pair<int, int> arr[n];
    for(int i = 0; i < n ; i++) cin >> arr[i].first >> arr[i].second;
    bool vals[n];
    memset(vals, false, sizeof(vals));
    for(int i = 0; i < k;i ++) {
        int a;
        cin >> a;
        for(int j  =0; j < n; j++) {
            if(vals[j] && arr[j].second <= a) vals[j] = false;
            else if(!vals[j] && arr[j].first <= a) vals[j] = true;
        }
    }
    int total = 0;
    for(int i = 0; i < n; i++) {
        if(vals[i]) total += arr[i].second;
        else total += arr[i].first;
    }
    cout<<total<<'\n';
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...