Submission #1033333

#TimeUsernameProblemLanguageResultExecution timeMemory
1033333VMaksimoski008Fortune Telling 2 (JOI14_fortune_telling2)C++17
4 / 100
3062 ms1768 KiB
#include <bits/stdc++.h>

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
//#define int long long

using namespace std;

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,bmi,bmi2,lzcnt,popcnt")


using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;

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

    int n, q;
    cin >> n >> q;

    vector<int> a(n+1), b(n+1);
    for(int i=1; i<=n; i++) cin >> a[i] >> b[i];

    while(q--) {
        int x;
        cin >> x;
        for(int i=1; i<=n; i++) if(a[i] <= x) swap(a[i], b[i]);
    }

    ll ans = 0;
    for(int i=1; i<=n; i++) ans += a[i];
    cout << ans << '\n';
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...