Submission #1039028

#TimeUsernameProblemLanguageResultExecution timeMemory
1039028c2zi6Teams (IOI15_teams)C++14
34 / 100
4037 ms31568 KiB
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define all(a) (a).begin(), (a).end() #define replr(i, a, b) for (int i = int(a); i <= int(b); ++i) #define reprl(i, a, b) for (int i = int(a); i >= int(b); --i) #define rep(i, n) for (int i = 0; i < int(n); ++i) #define mkp(a, b) make_pair(a, b) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<PII> VPI; typedef vector<VI> VVI; typedef vector<VVI> VVVI; typedef vector<VPI> VVPI; typedef pair<ll, ll> PLL; typedef vector<ll> VL; typedef vector<PLL> VPL; typedef vector<VL> VVL; typedef vector<VVL> VVVL; typedef vector<VPL> VVPL; template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;} template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;} #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<typename T> using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #include "teams.h" int n; VPI ranges; void init(int N, int A[], int B[]) { n = N; ranges = VPI(n); rep(i, n) ranges[i] = {A[i], B[i]}; } int can(int M, int K[]) { int m = M; VI a(m); rep(i, m) a[i] = K[i]; sort(all(a)); if (n <= 100) { VI used(n); for (int cur : a) { VPI tmp; rep(i, n) if (!used[i] && ranges[i].ff <= cur && cur <= ranges[i].ss) { tmp.pb({ranges[i].ss, i}); } sort(all(tmp)); if (tmp.size() < cur) return false; while (tmp.size() > cur) tmp.pop_back(); for (auto[r, i] : tmp) used[i] = true; } return true; } sort(all(ranges)); multiset<int> ms; int rpt = 0; for (int cur : a) { while (rpt != ranges.size() && ranges[rpt].ff <= cur) { ms.insert(ranges[rpt++].ss); } auto it = ms.lower_bound(cur); while (cur--) { if (it == ms.end()) return false; it++; ms.erase(prev(it)); } } return true; }

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:56:28: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   56 |             if (tmp.size() < cur) return false;
      |                 ~~~~~~~~~~~^~~~~
teams.cpp:57:31: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   57 |             while (tmp.size() > cur) tmp.pop_back();
      |                    ~~~~~~~~~~~^~~~~
teams.cpp:58:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   58 |             for (auto[r, i] : tmp) used[i] = true;
      |                      ^
teams.cpp:66:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |         while (rpt != ranges.size() && ranges[rpt].ff <= cur) {
      |                ~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...