Submission #1049505

#TimeUsernameProblemLanguageResultExecution timeMemory
1049505TAhmed33Teams (IOI15_teams)C++98
0 / 100
2982 ms14688 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 = 1; 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; } } 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}); } sort(k, k + m); 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; } int dp[m + 1] = {}; for (int i = 1; i <= m; i++) { dp[i] = query(1, k[i - 1], k[i - 1], n); for (int j = 1; j < i; j++) { dp[i] = max(dp[i], dp[j] + query(k[j - 1] + 1, k[i - 1], k[i - 1], n)); } dp[i] -= k[i - 1]; } return 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...