Submission #937891

#TimeUsernameProblemLanguageResultExecution timeMemory
937891danikoynovTeams (IOI15_teams)C++14
21 / 100
4053 ms10836 KiB
#include "teams.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; struct segment { int l, r; segment(int _l = 0, int _r = 0) { l = _l; r = _r; } }; const int maxn = 5e5 + 10; int n; segment s[maxn]; void init(int N, int A[], int B[]) { n = N; for (int i = 1; i <= n; i ++) { s[i] = segment(A[i - 1], B[i - 1]); } } int zeta(int a, int b) { int cnt = 0; for (int i = 1; i <= n; i ++) { if (s[i].l <= a && s[i].r >= a) continue; if (s[i].l <= b && s[i].r >= b) cnt ++; } return cnt; } int dp[maxn]; int can(int M, int K[]) { sort(K, K + M); for (int i = 0; i < M; i ++) { dp[i] = zeta(0, K[i]) - K[i]; for (int j = 0; j < i; j ++) { dp[i] = min(dp[i], dp[j] + zeta(K[j], K[i]) - K[i]); } if (dp[i] < 0) return 0; } return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...