Submission #1049512

#TimeUsernameProblemLanguageResultExecution timeMemory
1049512TAhmed33Teams (IOI15_teams)C++98
34 / 100
4070 ms14672 KiB
#include "teams.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 25; const int SZE = 400; int n; array <int, 2> a[MAXN]; void init(int N, int A[], int B[]) { n = N; for (int i = 0; i < n; i++) { a[i][0] = A[i]; } for (int i = 0; i < n; i++) { a[i][1] = B[i]; } sort(a, a + n); } vector <array <int, 3>> ee[MAXN]; int query (int x1, int y1, int x2, int y2) { int ret = 0; for (int i = 0; i < n; i++) { ret += (a[i][0] >= x1 && a[i][0] <= x2 && a[i][1] >= y1 && a[i][1] <= y2); } return ret; } int can (int m, int k[]) { int sum = 0; for (int i = 0; i < m; i++) { sum += k[i]; if (sum > n) { return 0; } } sort(k, k + m); if (m >= SZE) { for (int i = 1; i <= n; i++) { ee[i].clear(); } for (int i = 0; i < n; i++) { ee[a[i][0]].push_back({a[i][1], i, 1}); ee[a[i][1] + 1].push_back({a[i][1], i, -1}); } int ptr = 1; set <array <int, 2>> cur; for (int i = 0; i < m; i++) { while (ptr <= k[i]) { for (auto j : ee[ptr]) { if (j[2] == 1) { cur.insert({j[0], j[1]}); } else { cur.erase({j[0], j[1]}); } } ptr++; } if (cur.size() < k[i]) { return 0; } for (int j = 0; j < k[i]; j++) { cur.erase(cur.begin()); } } return 1; } long long dp[m] = {}; for (int i = 0; i < m; i++) { dp[i] = query(1, k[i], k[i], n); for (int j = 0; j < i; j++) { dp[i] = min(dp[i], dp[j] + query(k[j] + 1, k[i], k[i], n)); } dp[i] -= k[i]; } return *min_element(dp, dp + m) >= 0; }

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:56:19: warning: comparison of integer expressions of different signedness: 'std::set<std::array<int, 2> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   56 |    if (cur.size() < k[i]) {
      |        ~~~~~~~~~~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...