Submission #1039028

# Submission time Handle Problem Language Result Execution time Memory
1039028 2024-07-30T11:00:12 Z c2zi6 Teams (IOI15_teams) C++14
34 / 100
4000 ms 31568 KB
#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

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 time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 3 ms 440 KB Output is correct
13 Correct 2 ms 440 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 1884 KB Output is correct
2 Correct 12 ms 1964 KB Output is correct
3 Correct 35 ms 6196 KB Output is correct
4 Correct 14 ms 2652 KB Output is correct
5 Correct 14 ms 2032 KB Output is correct
6 Correct 19 ms 4184 KB Output is correct
7 Correct 8 ms 1884 KB Output is correct
8 Correct 8 ms 2020 KB Output is correct
9 Correct 22 ms 6888 KB Output is correct
10 Correct 22 ms 7252 KB Output is correct
11 Correct 24 ms 7096 KB Output is correct
12 Correct 22 ms 6992 KB Output is correct
13 Correct 26 ms 5468 KB Output is correct
14 Correct 31 ms 7512 KB Output is correct
15 Correct 13 ms 3672 KB Output is correct
16 Correct 12 ms 3160 KB Output is correct
17 Correct 21 ms 4620 KB Output is correct
18 Correct 21 ms 4188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 423 ms 2256 KB Output is correct
2 Correct 517 ms 2384 KB Output is correct
3 Execution timed out 4032 ms 6692 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1802 ms 9036 KB Output is correct
2 Correct 2076 ms 9036 KB Output is correct
3 Execution timed out 4037 ms 31568 KB Time limit exceeded
4 Halted 0 ms 0 KB -