# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1065125 |
2024-08-18T23:24:10 Z |
pawned |
Teams (IOI15_teams) |
C++17 |
|
4000 ms |
42428 KB |
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
#include "teams.h"
const int MAX = 1e5 + 5; // change to 1e5 + 5 later
int N;
vector<ii> allp;
void init(int N_g, int A_g[], int B_g[]) {
N = N_g;
for (int i = 0; i < N; i++) {
allp.pb({A_g[i], B_g[i]});
}
}
int can(int M, int K_g[]) {
vi teams;
for (int i = 0; i < M; i++) {
teams.pb(K_g[i]);
}
sort(teams.begin(), teams.end());
multiset<int> tr1[MAX]; // all end with start equal to i
multiset<int> tr2[MAX]; // all start with end equal to i
for (ii p : allp) {
tr1[p.fi].insert(p.se);
tr2[p.se].insert(p.fi);
}
multiset<ii> have; // all eligible {end, start}
// at each time, get best
int curr = 0; // minimum start
for (int i = 0; i < M; i++) {
// cout<<"at "<<i<<endl;
for (int j = curr + 1; j <= teams[i]; j++) { // add starting w/ j
for (int x : tr1[j]) {
// cout<<"inserting "<<x<<" "<<j<<endl;
have.insert({x, j});
}
}
for (int j = curr; j < teams[i]; j++) { // remove ending w/ j
for (int x : tr2[j]) {
have.erase(have.find({j, x}));
}
tr2[j].clear();
}
curr = teams[i];
for (int j = 0; j < teams[i]; j++) { // find team[i] of val team[i]
// cout<<"j: "<<j<<endl;
if (have.size() == 0) // run out
return 0;
ii minv = *(have.begin()); // lowest end, greedy
// cout<<"minv: "<<minv.fi<<", "<<minv.se<<endl;
have.erase(have.find(minv));
tr1[minv.se].erase(tr1[minv.se].find(minv.fi));
tr2[minv.fi].erase(tr2[minv.fi].find(minv.se));
}
}
return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
9816 KB |
Output is correct |
2 |
Correct |
5 ms |
9820 KB |
Output is correct |
3 |
Correct |
47 ms |
9844 KB |
Output is correct |
4 |
Correct |
50 ms |
9820 KB |
Output is correct |
5 |
Correct |
50 ms |
9824 KB |
Output is correct |
6 |
Correct |
6 ms |
9820 KB |
Output is correct |
7 |
Correct |
51 ms |
9816 KB |
Output is correct |
8 |
Correct |
58 ms |
10068 KB |
Output is correct |
9 |
Correct |
49 ms |
9816 KB |
Output is correct |
10 |
Correct |
48 ms |
9816 KB |
Output is correct |
11 |
Correct |
5 ms |
9820 KB |
Output is correct |
12 |
Correct |
53 ms |
9820 KB |
Output is correct |
13 |
Correct |
48 ms |
9816 KB |
Output is correct |
14 |
Correct |
53 ms |
9816 KB |
Output is correct |
15 |
Correct |
51 ms |
9820 KB |
Output is correct |
16 |
Correct |
50 ms |
9820 KB |
Output is correct |
17 |
Correct |
48 ms |
9820 KB |
Output is correct |
18 |
Correct |
51 ms |
9816 KB |
Output is correct |
19 |
Correct |
48 ms |
9816 KB |
Output is correct |
20 |
Correct |
54 ms |
9820 KB |
Output is correct |
21 |
Correct |
53 ms |
9820 KB |
Output is correct |
22 |
Correct |
49 ms |
9816 KB |
Output is correct |
23 |
Correct |
48 ms |
9820 KB |
Output is correct |
24 |
Correct |
49 ms |
9820 KB |
Output is correct |
25 |
Correct |
47 ms |
9820 KB |
Output is correct |
26 |
Correct |
52 ms |
9820 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
21708 KB |
Output is correct |
2 |
Correct |
36 ms |
21964 KB |
Output is correct |
3 |
Correct |
79 ms |
26052 KB |
Output is correct |
4 |
Correct |
35 ms |
22732 KB |
Output is correct |
5 |
Correct |
51 ms |
21516 KB |
Output is correct |
6 |
Correct |
58 ms |
21404 KB |
Output is correct |
7 |
Correct |
49 ms |
21448 KB |
Output is correct |
8 |
Correct |
42 ms |
21528 KB |
Output is correct |
9 |
Correct |
62 ms |
26572 KB |
Output is correct |
10 |
Correct |
55 ms |
26052 KB |
Output is correct |
11 |
Correct |
64 ms |
25796 KB |
Output is correct |
12 |
Correct |
52 ms |
25800 KB |
Output is correct |
13 |
Correct |
65 ms |
23508 KB |
Output is correct |
14 |
Correct |
65 ms |
26396 KB |
Output is correct |
15 |
Correct |
39 ms |
21712 KB |
Output is correct |
16 |
Correct |
42 ms |
21708 KB |
Output is correct |
17 |
Correct |
58 ms |
21800 KB |
Output is correct |
18 |
Correct |
61 ms |
21700 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4065 ms |
22636 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
50 ms |
42428 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |