Submission #1049454

#TimeUsernameProblemLanguageResultExecution timeMemory
1049454TAhmed33Teams (IOI15_teams)C++98
0 / 100
4046 ms58384 KiB
#include "teams.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 5e5 + 25; int n; array <int, 2> a[MAXN]; vector <array <int, 3>> ee[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); } int can (int m, int k[]) { int sum = 0; for (int i = 0; i < m; i++) { sum += k[i]; } 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.end()); } } return 1; }

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:45:18: warning: comparison of integer expressions of different signedness: 'std::set<std::array<int, 2> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   45 |   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...