Submission #1178964

#TimeUsernameProblemLanguageResultExecution timeMemory
1178964CodeLakVNFortune Telling 2 (JOI14_fortune_telling2)C++20
4 / 100
3092 ms688 KiB
#include <bits/stdc++.h>
using namespace std;

#define task "14O_fortune_telling2"
#define no "NO"
#define yes "YES"
#define F first
#define S second
#define vec vector
#define _mp make_pair
#define ii pair<int, int>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define evoid(val) return void(std::cout << val)
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FOD(i, b, a) for(int i = (b); i >= (a); --i)

const int N = (int)2e5 + 5;

int n, k;
ii cards[N];
int query[N];

void solve() {
    cin >> n >> k;
    FOR(i, 1, n) cin >> cards[i].F >> cards[i].S;
    FOR(i, 1, k) {
        int q;
        cin >> q;
        FOR(j, 1, n) if (cards[j].F <= q) swap(cards[j].F, cards[j].S);
    }
    long long ans = 0;
    FOR(i, 1, n) ans += cards[i].F;

    cout << ans;
}

int32_t main() {
    if (fopen(task".inp", "r")) {
        freopen(task".inp", "r", stdin);
        freopen(task".ans", "w", stdout);
    }
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    bool multitest = 0;
    int numTest = 1;
    if (multitest) cin >> numTest;

    while (numTest--) {
        solve();
    }

    return 0;
}

/* Lak lu theo dieu nhac!!!! */

Compilation message (stderr)

fortune_telling2.cpp: In function 'int32_t main()':
fortune_telling2.cpp:40:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
fortune_telling2.cpp:41:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |         freopen(task".ans", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...