# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
937560 |
2024-03-04T08:33:23 Z |
danikoynov |
Teams (IOI15_teams) |
C++14 |
|
4000 ms |
32564 KB |
#include "teams.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;
struct segment
{
int l, r;
segment(int _l = 0, int _r = 0)
{
l = _l;
r = _r;
}
};
int n;
segment s[maxn];
void init(int N, int A[], int B[])
{
n = N;
for (int i = 1; i <= n; i ++)
s[i] = A[i - 1];
}
struct event
{
int x, t, id;
event(int _x = 0, int _t = 0, int _id = 0)
{
x = _x;
t = _t;
id = _id;
}
};
bool cmp_event(event e1, event e2)
{
if (e1.x != e2.x)
return e1.x < e2.x;
return e1.t < e2.t;
}
int can(int M, int K[])
{
vector < event > events;
for (int i = 0; i < M; i ++)
{
events.push_back(event(K[i], 0, -1));
}
for (int i = 1; i <= n; i ++)
{
events.push_back(event(s[i].l, -1, i));
events.push_back(event(s[i].r, 1, i));
}
sort(events.begin(), events.end(), cmp_event);
set < pair < int, int > > act;
for (event cur : events)
{
if (cur.t == -1)
{
act.insert({s[cur.id].r, cur.id});
}
else
if (cur.t == 1)
{
if (act.find({s[cur.id].r, cur.id}) != act.end())
{
return 0;
act.erase({s[cur.id].r, cur.id});
}
}
else
{
if (act.size() < cur.x)
{
return 0;
}
for (int d = 0; d < cur.x; d ++)
act.erase(act.begin());
}
}
return 1;
}
Compilation message
teams.cpp: In function 'void init(int, int*, int*)':
teams.cpp:19:31: warning: unused parameter 'B' [-Wunused-parameter]
19 | void init(int N, int A[], int B[])
| ~~~~^~~
teams.cpp: In function 'int can(int, int*)':
teams.cpp:79:28: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
79 | if (act.size() < cur.x)
| ~~~~~~~~~~~^~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4188 KB |
Output is correct |
2 |
Correct |
2 ms |
4188 KB |
Output is correct |
3 |
Correct |
3 ms |
4188 KB |
Output is correct |
4 |
Correct |
3 ms |
4188 KB |
Output is correct |
5 |
Incorrect |
3 ms |
4188 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
9428 KB |
Output is correct |
2 |
Correct |
25 ms |
8120 KB |
Output is correct |
3 |
Incorrect |
56 ms |
11696 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3582 ms |
11044 KB |
Output is correct |
2 |
Execution timed out |
4078 ms |
11264 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4021 ms |
32564 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |