Submission #394600

#TimeUsernameProblemLanguageResultExecution timeMemory
394600shivensinha4Teams (IOI15_teams)C++17
0 / 100
100 ms14668 KiB
#include "bits/stdc++.h" #include "teams.h" using namespace std; #define for_(i, s, e) for (int i = s; i < (int) e; i++) #define for__(i, s, e) for (ll i = s; i < e; i++) typedef long long ll; typedef vector<int> vi; typedef array<int, 2> ii; // #define endl '\n' int n; vi endbefore, beginafter; // both inclusive: before -> <=, after -> >= void init(int N, int A[], int B[]) { n = N; endbefore.resize(n); beginafter.resize(n); for_(i, 0, n) { endbefore[B[i]-1]++; beginafter[A[i]-1]++; } for_(i, 1, n) endbefore[i] += endbefore[i-1]; for (int i = n-2; i >= 0; i--) beginafter[i] += beginafter[i+1]; } int can(int M, int K[]) { // return 0; for_(i, 0, M) K[i] -= 1; sort(K, K+M); int mx = 0; vi psum(M+1); for_(i, 0, M) psum[i] += K[i]+1; for_(i, 1, M+1) psum[i] += psum[i-1]; // cout << "yoyo!" << endl; vi sufmx(M+1); for (int i = M; i >= 0; i--) { int ba; if (i < M) ba = K[i] < n-1 ? beginafter[K[i]+1] : 0; else ba = K[M-1] < n-1 ? beginafter[K[M-1]+1] : 0; sufmx[i] = psum[i] + ba; if (i < M) sufmx[i] = max(sufmx[i], sufmx[i+1]); } // if (K[M-1]+1 < n) { // int ba = K[M-1]+1 < n ? beginafter[K[M-1]+1] : 0; // int eb = K[M-1]-1 >= 0 ? endbefore[K[M-1]-1] : 0; // mx = K[M-1]+1 + ba + eb; // } for_(i, 0, M) { int val = (K[i] >= 1 ? endbefore[K[i]-1] : 0) - (i > 0 ? psum[i-1] : 0) + sufmx[i]; mx = max(mx, val); } return mx <= n; } // int main() { // #ifdef mlocal // freopen("teams.in", "r", stdin); // #endif // ios_base::sync_with_stdio(false); // cin.tie(0); // int t; cin >> t; // cout << "got " << t << endl; // while (t--) { // } // }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...