Submission #1519172
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
struct starry_sky_tree {
int size;
vector<int> data;
vector<int> lazy;
vector<int> width;
starry_sky_tree(int n) {
size = 1;
while (size < n) size <<= 1;
data.resize(size*2, 0);
lazy.resize(size*2, 0);
width.resize(size*2, 1);
for (int i = size-2; i >= 0; i--) {
width[i] = width[i*2+1] ; width[i*2+2];
}
}
void lazy_propagate(int p) {
data[p] += lazy[p];
if (p < size-1) {
lazy[p*2+1] += lazy[p];
lazy[p*2+2] += lazy[p];
}
lazy[p] = 0;
}
void add(int wishl, int wishr, int x) {
add(wishl, wishr, 0, size, 0, x);
}
void add(int wishl, int wishr, int watchl, int watchr, int k, int x) {
if (wishr <= watchl || watchr <= wishl) {
lazy_propagate(k);
return;
}
if (wishl <= watchl && watchr <= wishr) {
lazy[k] += x;
lazy_propagate(k);
return;
}
int mid = (watchl + watchr) / 2;
lazy_propagate(k);
add(wishl, wishr, watchl, mid, k*2+1, x);
add(wishl, wishr, mid, watchr, k*2+2, x);
data[k] = max(data[k*2+1], data[k*2+2]);
}
int getmax(int wishl, int wishr) {
return getmax(wishl, wishr, 0, size, 0);
}
int getmax(int wishl, int wishr, int watchl, int watchr, int k) {
if (wishr <= watchl || watchr <= wishl) return 0;
if (wishl <= watchl && watchr <= wishr) {
lazy_propagate(k);
return data[k];
}
int mid = (watchl + watchr) / 2;
int L = getmax(wishl, wishr, watchl, mid, k*2+1);
int R = getmax(wishl, wishr, mid, watchr, k*2+2);
return max(L, R);
}
};
int main() {
starry_sky_tree sst(100005);
int n;
cin >> n;
vector<int> s(n), t(n);
for (int i = 0; i < n; i++) {
cin >> s[i] >> t[i];
sst.add(s[i], t[i], 1);
}
int ans = sst.getmax(0, 100005);
for (int i = 0; i < n; i++) {
sst.add(s[i], t[i], -1);
int tmp = sst.getmax(0, 100005);
if (ans > tmp) {
ans = tmp;
}
sst.add(s[i], t[i], 1);
}
cout << ans << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
D - 足ゲームII |
User |
algon |
Language |
C++14 (GCC 5.4.1) |
Score |
100 |
Code Size |
2390 Byte |
Status |
AC |
Exec Time |
230 ms |
Memory |
4096 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
100 / 100 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample-01.txt, sample-02.txt, sample-03.txt |
All |
sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, sample-01.txt, sample-02.txt, sample-03.txt |
Case Name |
Status |
Exec Time |
Memory |
01-01.txt |
AC |
3 ms |
3328 KB |
01-02.txt |
AC |
3 ms |
3328 KB |
01-03.txt |
AC |
3 ms |
3328 KB |
01-04.txt |
AC |
5 ms |
3328 KB |
01-05.txt |
AC |
224 ms |
4096 KB |
01-06.txt |
AC |
224 ms |
4096 KB |
01-07.txt |
AC |
223 ms |
4096 KB |
01-08.txt |
AC |
224 ms |
4096 KB |
01-09.txt |
AC |
223 ms |
4096 KB |
01-10.txt |
AC |
3 ms |
3328 KB |
01-11.txt |
AC |
223 ms |
4096 KB |
01-12.txt |
AC |
224 ms |
4096 KB |
01-13.txt |
AC |
224 ms |
4096 KB |
01-14.txt |
AC |
225 ms |
4096 KB |
01-15.txt |
AC |
7 ms |
3328 KB |
01-16.txt |
AC |
223 ms |
4096 KB |
01-17.txt |
AC |
224 ms |
4096 KB |
01-18.txt |
AC |
223 ms |
4096 KB |
01-19.txt |
AC |
230 ms |
4096 KB |
01-20.txt |
AC |
7 ms |
3328 KB |
01-21.txt |
AC |
223 ms |
4096 KB |
01-22.txt |
AC |
221 ms |
4096 KB |
01-23.txt |
AC |
221 ms |
4096 KB |
01-24.txt |
AC |
186 ms |
4096 KB |
01-25.txt |
AC |
3 ms |
3328 KB |
01-26.txt |
AC |
3 ms |
3328 KB |
01-27.txt |
AC |
150 ms |
4096 KB |
01-28.txt |
AC |
149 ms |
4096 KB |
sample-01.txt |
AC |
3 ms |
3328 KB |
sample-02.txt |
AC |
3 ms |
3328 KB |
sample-03.txt |
AC |
3 ms |
3328 KB |