Submission #914193

# Submission time Handle Problem Language Result Execution time Memory
914193 2024-01-21T10:40:36 Z mcdx9524 Gym Badges (NOI22_gymbadges) C++17
100 / 100
483 ms 48852 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

struct Job {
    int deadline, duration, idx;

    bool operator<(Job o) const {
        return deadline < o.deadline;
    }
};

vector<int> compute_schedule(vector<Job> jobs) {
    sort(jobs.begin(), jobs.end());

    set<pair<int,int>> s;
    vector<int> schedule;
    for (int i = jobs.size()-1; i >= 0; i--) {
        int t = jobs[i].deadline - (i ? jobs[i-1].deadline : 0);
        s.insert(make_pair(jobs[i].duration, jobs[i].idx));
        while (t && !s.empty()) {
            auto it = s.begin();
            if (it->first <= t) {
                t -= it->first;
                schedule.push_back(it->second);
            } else {
                s.insert(make_pair(it->first - t, it->second));
                t = 0;
            }
            s.erase(it);
        }
    }
    return schedule;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector <int> x(n), y(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> y[i];
    }
    vector <Job> jobs;
    for (int i = 0; i < n; i++) {
        swap(x[i], y[i]);
        jobs.push_back({x[i] + y[i], y[i], i});
    }
    auto ans = compute_schedule(jobs);
    cout << (int) ans.size() << '\n'; 
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 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 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 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 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 220 ms 39512 KB Output is correct
2 Correct 214 ms 48540 KB Output is correct
3 Correct 210 ms 48760 KB Output is correct
4 Correct 207 ms 48572 KB Output is correct
5 Correct 213 ms 48852 KB Output is correct
6 Correct 194 ms 47864 KB Output is correct
7 Correct 191 ms 47292 KB Output is correct
8 Correct 197 ms 47796 KB Output is correct
9 Correct 193 ms 47804 KB Output is correct
10 Correct 194 ms 47604 KB Output is correct
11 Correct 204 ms 46560 KB Output is correct
12 Correct 186 ms 46780 KB Output is correct
13 Correct 196 ms 46776 KB Output is correct
14 Correct 197 ms 47112 KB Output is correct
15 Correct 195 ms 46780 KB Output is correct
16 Correct 191 ms 47088 KB Output is correct
17 Correct 195 ms 47132 KB Output is correct
18 Correct 193 ms 47340 KB Output is correct
19 Correct 196 ms 47456 KB Output is correct
20 Correct 192 ms 47344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 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 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 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 0 ms 348 KB Output is correct
21 Correct 3 ms 860 KB Output is correct
22 Correct 3 ms 860 KB Output is correct
23 Correct 3 ms 860 KB Output is correct
24 Correct 3 ms 860 KB Output is correct
25 Correct 3 ms 860 KB Output is correct
26 Correct 3 ms 860 KB Output is correct
27 Correct 3 ms 860 KB Output is correct
28 Correct 3 ms 860 KB Output is correct
29 Correct 3 ms 860 KB Output is correct
30 Correct 3 ms 860 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 3 ms 604 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 3 ms 604 KB Output is correct
35 Correct 2 ms 860 KB Output is correct
36 Correct 2 ms 856 KB Output is correct
37 Correct 2 ms 604 KB Output is correct
38 Correct 3 ms 588 KB Output is correct
39 Correct 3 ms 604 KB Output is correct
40 Correct 2 ms 604 KB Output is correct
41 Correct 2 ms 604 KB Output is correct
42 Correct 2 ms 604 KB Output is correct
43 Correct 2 ms 604 KB Output is correct
44 Correct 2 ms 604 KB Output is correct
45 Correct 2 ms 604 KB Output is correct
46 Correct 2 ms 604 KB Output is correct
47 Correct 2 ms 604 KB Output is correct
48 Correct 3 ms 860 KB Output is correct
49 Correct 2 ms 604 KB Output is correct
50 Correct 2 ms 932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 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 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 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 0 ms 348 KB Output is correct
21 Correct 220 ms 39512 KB Output is correct
22 Correct 214 ms 48540 KB Output is correct
23 Correct 210 ms 48760 KB Output is correct
24 Correct 207 ms 48572 KB Output is correct
25 Correct 213 ms 48852 KB Output is correct
26 Correct 194 ms 47864 KB Output is correct
27 Correct 191 ms 47292 KB Output is correct
28 Correct 197 ms 47796 KB Output is correct
29 Correct 193 ms 47804 KB Output is correct
30 Correct 194 ms 47604 KB Output is correct
31 Correct 204 ms 46560 KB Output is correct
32 Correct 186 ms 46780 KB Output is correct
33 Correct 196 ms 46776 KB Output is correct
34 Correct 197 ms 47112 KB Output is correct
35 Correct 195 ms 46780 KB Output is correct
36 Correct 191 ms 47088 KB Output is correct
37 Correct 195 ms 47132 KB Output is correct
38 Correct 193 ms 47340 KB Output is correct
39 Correct 196 ms 47456 KB Output is correct
40 Correct 192 ms 47344 KB Output is correct
41 Correct 3 ms 860 KB Output is correct
42 Correct 3 ms 860 KB Output is correct
43 Correct 3 ms 860 KB Output is correct
44 Correct 3 ms 860 KB Output is correct
45 Correct 3 ms 860 KB Output is correct
46 Correct 3 ms 860 KB Output is correct
47 Correct 3 ms 860 KB Output is correct
48 Correct 3 ms 860 KB Output is correct
49 Correct 3 ms 860 KB Output is correct
50 Correct 3 ms 860 KB Output is correct
51 Correct 2 ms 604 KB Output is correct
52 Correct 3 ms 604 KB Output is correct
53 Correct 2 ms 604 KB Output is correct
54 Correct 3 ms 604 KB Output is correct
55 Correct 2 ms 860 KB Output is correct
56 Correct 2 ms 856 KB Output is correct
57 Correct 2 ms 604 KB Output is correct
58 Correct 3 ms 588 KB Output is correct
59 Correct 3 ms 604 KB Output is correct
60 Correct 2 ms 604 KB Output is correct
61 Correct 2 ms 604 KB Output is correct
62 Correct 2 ms 604 KB Output is correct
63 Correct 2 ms 604 KB Output is correct
64 Correct 2 ms 604 KB Output is correct
65 Correct 2 ms 604 KB Output is correct
66 Correct 2 ms 604 KB Output is correct
67 Correct 2 ms 604 KB Output is correct
68 Correct 3 ms 860 KB Output is correct
69 Correct 2 ms 604 KB Output is correct
70 Correct 2 ms 932 KB Output is correct
71 Correct 1 ms 348 KB Output is correct
72 Correct 1 ms 348 KB Output is correct
73 Correct 415 ms 48728 KB Output is correct
74 Correct 421 ms 48744 KB Output is correct
75 Correct 403 ms 48628 KB Output is correct
76 Correct 403 ms 48484 KB Output is correct
77 Correct 458 ms 48744 KB Output is correct
78 Correct 431 ms 45240 KB Output is correct
79 Correct 367 ms 45812 KB Output is correct
80 Correct 358 ms 45240 KB Output is correct
81 Correct 410 ms 45576 KB Output is correct
82 Correct 452 ms 45240 KB Output is correct
83 Correct 292 ms 39356 KB Output is correct
84 Correct 277 ms 39584 KB Output is correct
85 Correct 266 ms 39388 KB Output is correct
86 Correct 316 ms 39352 KB Output is correct
87 Correct 281 ms 39756 KB Output is correct
88 Correct 216 ms 33548 KB Output is correct
89 Correct 218 ms 33776 KB Output is correct
90 Correct 223 ms 33512 KB Output is correct
91 Correct 214 ms 33468 KB Output is correct
92 Correct 220 ms 33400 KB Output is correct
93 Correct 199 ms 29680 KB Output is correct
94 Correct 206 ms 29884 KB Output is correct
95 Correct 187 ms 29944 KB Output is correct
96 Correct 190 ms 30392 KB Output is correct
97 Correct 187 ms 29848 KB Output is correct
98 Correct 483 ms 47804 KB Output is correct
99 Correct 425 ms 47808 KB Output is correct
100 Correct 385 ms 47976 KB Output is correct
101 Correct 173 ms 27248 KB Output is correct
102 Correct 149 ms 27068 KB Output is correct