ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#213913 | #2400. 椅子 | WZRYWZWY | 100 | 3456ms | 10508kb | C++11 | 2.4kb | 2024-11-14 18:41:27 | 2024-11-14 23:00:24 |
answer
#include <stdio.h> //https://atcoder.jp/contests/arc076/submissions/1375605
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
#define mp make_pair
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
#define ldb ldouble
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
vector <int> Vv[200050];
priority_queue <int, vector<int>, greater<int>> Hx;
vector <int> Vu;
ll getv(int a, int M) {
int i;
while (!Hx.empty()) Hx.pop();
Vu.clear();
for (i = 1; i <= M; i++) {
for (auto it : Vv[i]) Hx.push(it);
if (i >= M - a + 1) {
if (Hx.empty()) return -LL_INF;
Hx.pop();
}
}
for (auto it : Vv[M + 1]) Hx.push(it);
while (!Hx.empty()) {
Vu.push_back(Hx.top());
Hx.pop();
}
int st = 1, en = min((int)Vu.size(), M - a), mi, rv = 0;
while (st <= en) {
mi = (st + en) / 2;
for (i = 0; i < mi; i++) if (Vu[Vu.size() - mi + i] < i + 1) break;
if (i >= mi) {
rv = mi;
st = mi + 1;
}
else en = mi - 1;
}
return a + rv;
}
int main() {
int N, M, i, j;
scanf("%d %d", &N, &M);
//N = 200000, M = 199999;
for (i = 1; i <= N; i++) {
int t1, t2;
scanf("%d %d", &t1, &t2);
//t1 = 1, t2 = 2;
Vv[t2].push_back(t1);
}
int st = 0, en = min(N, M), mi;
while (st < en) {
int mi1 = (st + en) / 2;
int mi2 = mi1 + 1;
ll v1 = getv(mi1, M);
ll v2 = getv(mi2, M);
if (v1 >= v2) en = mi2 - 1;
else st = mi1 + 1;
}
ll v = getv(st, M);
return !printf("%lld\n", N - v);
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 5
Accepted
time: 0ms
memory: 5936kb
input:
8 8 1 8 1 5 2 8 0 5 0 3 2 6 2 6 2 6
output:
1
result:
ok single line: '1'
Test #2:
score: 5
Accepted
time: 0ms
memory: 5940kb
input:
10 10 0 5 2 9 3 10 2 7 1 6 0 10 0 9 2 10 0 9 1 10
output:
2
result:
ok single line: '2'
Test #3:
score: 5
Accepted
time: 0ms
memory: 5940kb
input:
20 20 4 16 2 11 3 19 6 12 7 18 1 14 4 10 5 20 6 14 8 17 1 12 2 11 7 18 7 15 0 15 1 12 2 19 7 13 4 10...
output:
1
result:
ok single line: '1'
Test #4:
score: 5
Accepted
time: 0ms
memory: 5940kb
input:
96 93 2 67 5 61 4 74 15 68 3 63 40 91 14 58 6 66 9 57 18 85 13 63 40 85 17 89 16 73 10 72 15 74 15 6...
output:
7
result:
ok single line: '7'
Test #5:
score: 5
Accepted
time: 2ms
memory: 5940kb
input:
100 100 29 70 17 68 25 77 13 74 9 79 42 90 34 99 18 100 3 80 21 71 26 63 6 54 43 89 41 78 19 78 13 9...
output:
2
result:
ok single line: '2'
Test #6:
score: 5
Accepted
time: 0ms
memory: 5964kb
input:
952 954 182 871 114 769 110 694 91 741 22 509 53 841 124 858 16 465 160 789 24 720 96 939 56 689 313...
output:
64
result:
ok single line: '64'
Test #7:
score: 5
Accepted
time: 0ms
memory: 5960kb
input:
1000 1000 74 795 175 641 39 618 19 971 162 873 93 731 480 989 357 932 4 693 266 965 89 581 47 560 27...
output:
74
result:
ok single line: '74'
Test #8:
score: 5
Accepted
time: 4ms
memory: 6048kb
input:
4516 4690 665 4024 1062 3765 1573 4200 1035 4155 441 2678 31 3472 87 3450 146 2286 310 4267 1231 450...
output:
69
result:
ok single line: '69'
Test #9:
score: 5
Accepted
time: 8ms
memory: 6052kb
input:
5000 5000 62 4476 1146 3647 531 4569 1042 3464 2044 4817 2186 4584 2223 4892 1224 4761 1154 4943 147...
output:
250
result:
ok single line: '250'
Test #10:
score: 5
Accepted
time: 13ms
memory: 6156kb
input:
10000 5000 1106 4454 1138 4746 926 4805 609 4507 259 4543 1435 4211 790 3399 528 3426 38 4665 87 404...
output:
5347
result:
ok single line: '5347'
Test #11:
score: 5
Accepted
time: 15ms
memory: 6168kb
input:
10000 10000 2224 8599 3697 9779 1264 7760 266 8474 601 9386 5276 9907 4231 9619 2206 8589 3306 9731 ...
output:
574
result:
ok single line: '574'
Test #12:
score: 5
Accepted
time: 114ms
memory: 8144kb
input:
93875 99655 0 25859 0 30798 0 89053 0 29230 0 93483 0 83280 0 47502 0 39669 0 69861 0 64184 0 35067 ...
output:
14154
result:
ok single line: '14154'
Test #13:
score: 5
Accepted
time: 182ms
memory: 8144kb
input:
100000 100000 0 50602 0 56129 0 65965 0 75241 0 71832 0 26413 0 79671 0 73842 0 78772 0 94149 0 3483...
output:
25000
result:
ok single line: '25000'
Test #14:
score: 5
Accepted
time: 106ms
memory: 7652kb
input:
91057 96847 21419 89318 2406 89095 2941 51033 14888 77083 28023 74840 18260 62296 6297 51346 7735 88...
output:
134
result:
ok single line: '134'
Test #15:
score: 5
Accepted
time: 320ms
memory: 8120kb
input:
100000 100000 16723 78322 7205 66894 9839 72285 7661 85725 38680 93140 6182 88375 30785 99006 38538 ...
output:
5118
result:
ok single line: '5118'
Test #16:
score: 5
Accepted
time: 458ms
memory: 10484kb
input:
198495 197435 63738 165927 17757 117506 9207 170263 50748 141346 18132 120887 49285 188664 25304 190...
output:
11098
result:
ok single line: '11098'
Test #17:
score: 5
Accepted
time: 510ms
memory: 10452kb
input:
199260 192470 22818 156104 9228 171776 43025 139453 39938 135662 18272 171006 68109 171295 28220 116...
output:
15568
result:
ok single line: '15568'
Test #18:
score: 5
Accepted
time: 439ms
memory: 10504kb
input:
200000 200000 75002 167675 8656 181873 54606 156991 48075 167451 74414 194621 55633 180796 4565 1657...
output:
10484
result:
ok single line: '10484'
Test #19:
score: 5
Accepted
time: 614ms
memory: 10500kb
input:
200000 200000 59298 170956 2760 194028 35447 153792 1945 163425 73195 176225 62065 185526 85886 1916...
output:
10543
result:
ok single line: '10543'
Test #20:
score: 5
Accepted
time: 671ms
memory: 10508kb
input:
200000 200000 67496 171474 36806 170296 86759 193181 7951 171117 85324 184470 8949 171983 10465 1547...
output:
10575
result:
ok single line: '10575'
Extra Test:
score: 0
Extra Test Passed