Submission #937890

#TimeUsernameProblemLanguageResultExecution timeMemory
937890danikoynovTeams (IOI15_teams)C++14
0 / 100
4069 ms14648 KiB
#include "teams.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; struct segment { ll l, r; segment(ll _l = 0, ll _r = 0) { l = _l; r = _r; } }; const ll maxn = 5e5 + 10; ll n; segment s[maxn]; void init(int N, int A[], int B[]) { n = N; for (ll i = 1; i <= n; i ++) { s[i] = segment(A[i - 1], B[i - 1]); } } ll zeta(ll a, ll b) { ll cnt = 0; for (ll 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; } ll dp[maxn]; int can(int M, int K[]) { for (ll i = 0; i < M; i ++) { dp[i] = zeta(0, K[i]) - K[i]; for (ll 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...