Submission #592796

#TimeUsernameProblemLanguageResultExecution timeMemory
592796skittles1412Jousting tournament (IOI12_tournament)C++17
17 / 100
1085 ms1372 KiB
#include "bits/extc++.h"

using namespace std;

template <typename T>
void dbgh(const T& t) {
    cerr << t << endl;
}

template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
    cerr << t << " | ";
    dbgh(u...);
}

#ifdef DEBUG
#define dbg(...)                                              \
    cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]: "; \
    dbgh(__VA_ARGS__);
#else
#define dbg(...)
#define cerr   \
    if (false) \
    cerr
#endif

#define endl "\n"
#define long int64_t
#define sz(x) int((x).size())

int GetBestPosition(int n, int m, int k, int* arr, int* arrl, int* arrr) {
    pair<int, int> ans {-1, 0};
    for (int i = 0; i < n; i++) {
        vector<int> carr(arr, arr + n - 1);
        carr.insert(carr.begin() + i, k);
        int cans = 0;
        for (int i = 0; i < m; i++) {
            int l = arrl[i], r = arrr[i];
            auto cl = carr.begin() + l;
            auto cr = carr.begin() + r + 1;
            int w = *max_element(cl, cr);
            carr.erase(cl, cr);
            carr.insert(carr.begin() + l, w);
            cans += w == k;
        }
        ans = max(ans, pair<int, int> {cans, -i});
    }
    return -ans.second;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...