Submission #288982

#TimeUsernameProblemLanguageResultExecution timeMemory
288982BertedTeams (IOI15_teams)C++14
0 / 100
35 ms8320 KiB
#include "teams.h" #include <iostream> #include <utility> #include <algorithm> #include <vector> #include <bitset> #define pii pair<int, int> #define fst first #define snd second const int SZ = (1 << 20) + 5, SZ2 = 500005; using namespace std; struct p_node { int v = 0, l = -1, r = -1; p_node() {} }; int n; pii a[105]; int pref[105], suf[105], t[105]; bool valid[105]; void init(int N, int A[], int B[]) { n = N; for (int i = 0; i < N; i++) {a[i] = {A[i], B[i]}; pref[B[i]]++; suf[A[i]]++;} for (int i = 1; i <= n + 1; i++) {pref[i] += pref[i - 1];} for (int i = n; i >= 0; i--) {suf[i] += suf[i + 1];} } int can(int M, int K[]) { //cout << "New " << M << "\n"; sort(K, K + M); int ret = 1; for (int i = 0; i < M; i++) { valid[K[i]] = 1; if (i) { int add = 0; for (int j = 0; j < n; j++) { if (K[i - 1] < a[j].fst && a[j].snd < K[i]) {add++;} } for (int j = 1; j <= K[i - 1]; j++) {t[j] += add;} } for (int j = 1; j <= K[i]; j++) {t[j] += K[i];} for (int j = 1; j <= K[i]; j++) { //cout << i << " " << j << " " << pref[j - 1] << " " << suf[K[i] + 1] << " " << t[j] << "\n"; if (valid[j] && pref[j - 1] + suf[K[i] + 1] + t[j] > n) {ret = 0;} } } for (int i = 0; i <= n + 2; i++) {t[i] = 0; valid[i] = 0;} return ret; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...