Submission #1100739

# Submission time Handle Problem Language Result Execution time Memory
1100739 2024-10-14T14:47:08 Z RiverFlow Teams (IOI15_teams) C++14
0 / 100
4000 ms 27980 KB
#include <bits/stdc++.h>

#define nl "\n"
#define no "NO"
#define yes "YES"
#define fi first
#define se second
#define vec vector
#define task "main"
#define _mp make_pair
#define ii pair<int, int>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define evoid(val) return void(std::cout << val)
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FOD(i, b, a) for(int i = (b); i >= (a); --i)
#define unq(x) sort(all(x)); x.resize(unique(all(x)) - x.begin())

using namespace std;

template<typename U, typename V> bool maxi(U &a, V b) {
    if (a < b) { a = b; return 1; } return 0;
}
template<typename U, typename V> bool mini(U &a, V b) {
    if (a > b) { a = b; return 1; } return 0;
}

const int N = (int)2e5 + 9;
const int mod = (int)1e9 + 7;

void prepare(); void main_code();

int n, m;

int a[N], b[N], k[N];

vector<int> ins[N];

void init(int N, int A[], int B[]) {
    n = N;
    FOR(i, 0, n - 1) {
        a[i] = A[i], b[i] = B[i];
        ins[a[i]].push_back(i);
    }
}

int can(int M, int K[]) {
	priority_queue<ii, vec<ii>, greater<ii>> pq;
    m = M;
    FOR(i, 0, m - 1) k[i] = K[i];
    for(int i = 0, lst = -1; i < m; ++i) {
        int x = k[i];
        while (lst + 1 <= x) {
            ++lst;
            for(int j : ins[lst]) {
                pq.push(_mp(b[j], j));
            }
        }
        int t = x;
        while (t > 0) {
            if (sz(pq) == 0) {
                t = -1; break ;
            }
            while (sz(pq) and b[pq.top().se] < x) {
                pq.pop();
            }
            if (sz(pq)) {
                pq.pop();
                --t;
            }
        }
        if (t == -1) {
            return 0;
        }
        lst = x;
    }
    return 1;
}

#ifdef LOCAL
int aa[N], bb[N], kk[N];
int main() {
    freopen("main.inp", "r", stdin);
    freopen("main.out", "w", stdout);
    int n; cin >> n;
    FOR(i, 0, n - 1) cin >> aa[i] >> bb[i];
    init(n, aa, bb);
    int q; cin >> q;
    while (q--) {
        int m; cin >> m;
        FOR(i, 0, m - 1) cin >> kk[i];
        cout << can(m, kk) << nl;
    }
}
#endif

Compilation message

teams.cpp: In function 'void init(int, int*, int*)':
teams.cpp:39:15: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   39 | void init(int N, int A[], int B[]) {
      |           ~~~~^
teams.cpp:28:11: note: shadowed declaration is here
   28 | const int N = (int)2e5 + 9;
      |           ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6740 KB Output is correct
2 Incorrect 2 ms 6740 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 10836 KB Output is correct
2 Correct 13 ms 10836 KB Output is correct
3 Correct 25 ms 11816 KB Output is correct
4 Correct 16 ms 11200 KB Output is correct
5 Incorrect 12 ms 9936 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 34 ms 11484 KB Output is correct
2 Correct 38 ms 11580 KB Output is correct
3 Execution timed out 4074 ms 12888 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 48 ms 27980 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -