UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#215167#2441. 物品KinNa0500ms7104kbC++111.8kb2024-11-26 21:52:202024-11-26 23:06:15

answer

/**
* @author: KinNa
* @date: none
*/

bool CalcM1;
#include <bits/stdc++.h>
#define rep(i, a, b) for (long long i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (long long i = (a), i##end = (b); i >= i##end; --i)
#define file(x) freopen(#x".in", "r", stdin); freopen(#x".out", "w", stdout);
#define fi first
#define se second
#define LOOK_TIME cerr << (1.0 * clock() / CLOCKS_PER_SEC) << endl;
using namespace std;
using LL = long long;
using iLL = __int128;
using PII = pair <int, int>;
const int N = 5e5 + 10;

template <typename T> T Read(T &x) {
	x = 0; bool f = 0; char c = getchar(); while (!isdigit(c)) f = c == '-', c = getchar();
	while (isdigit(c)) x = x * 10 + c - '0', c = getchar(); return x = f ? -x : x;
}
template <typename T> T R(T &x) {return Read(x);}
template <typename T, typename... Tr> void R(T &x, Tr&... y) {Read(x); R(y...);}

int n, C, ans, ansm;
struct Node {int a, w, id;} qwq[N];

bool check(int m) {
	int W = 0, now = 0;
	rep(i, 1, n) if (qwq[i].a >= m) {
		if (W + qwq[i].w > C) break;
		W += qwq[i].w; ++now;
		if (now == m) break;
	}
	if (now > ans) ans = now, ansm = m;
	return now == m;
}

bool CalcM2;
int main() {
#ifndef ONLINE_JUDGE
	file(a)
#endif
	cerr << (&CalcM2 - &CalcM1) / 1048576.0 << "\n";

	R(n, C);
	rep(i, 1, n) R(qwq[i].a, qwq[i].w), qwq[i].id = i;
	sort(qwq + 1, qwq + n + 1, [&](Node A, Node B) {return A.w < B.w;});
	int l = 1, r = n, res = -1;
	while (l <= r) {
		int mid = l + r >> 1;
		if (check(mid)) res = mid, l = mid + 1;
		else r = mid - 1;
	}
	cout << ans << endl << ans << endl;
	int W = 0, now = 0;
	rep(i, 1, n) if (qwq[i].a >= ansm) {
		if (W + qwq[i].w > C) break;
		cout << i << " ";
		W += qwq[i].w; ++now;
		if (now == ansm) break;
	}
	return 0;
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 1264kb

input:

18 1024
8 3
8 1
16 9
17 6
2 5
12 3
1 7
7 9
17 1
14 3
2 7
17 5
2 3
2 5
2 10
8 3
2 3
17 5

output:

8
8
1 2 3 5 7 8 9 12 

result:

wrong answer Incorrect solution!

Test #2:

score: 0
Wrong Answer
time: 0ms
memory: 1264kb

input:

20 79841
15 4337
9 6289
7 9927
12 1468
7 9390
12 9228
7 5646
8 3438
3 1614
3 7048
10 8840
15 2349
16...

output:

10
10
1 3 4 6 7 14 15 16 17 20 

result:

wrong answer Incorrect solution!

Test #3:

score: 0
Wrong Answer
time: 0ms
memory: 1284kb

input:

1888 987654
1082 243
1341 309
1524 959
324 593
894 952
1428 587
1367 91
1669 683
616 866
958 791
172...

output:

949
949
2 3 5 6 7 8 9 10 11 13 17 19 22 23 26 27 35 38 42 48 52 53 56 58 60 62 64 65 66 67 69 71 72 ...

result:

wrong answer Incorrect solution!

Test #4:

score: 0
Wrong Answer
time: 0ms
memory: 1288kb

input:

1999 12000000
1112 2799
524 6890
686 6713
1803 4478
940 4341
1391 8972
953 592
454 7711
524 8224
127...

output:

978
978
2 4 5 7 8 9 10 11 17 20 21 23 24 25 27 28 29 30 33 35 36 38 39 40 41 43 47 49 50 52 64 65 68...

result:

wrong answer Incorrect solution!

Test #5:

score: 0
Wrong Answer
time: 0ms
memory: 1284kb

input:

2000 9788123
296 3976
154 3441
78 9146
1443 6444
1799 2843
1482 6843
1526 3159
1956 9324
1442 1001
5...

output:

997
997
3 4 5 7 9 11 15 18 20 21 22 24 26 27 28 29 32 35 37 40 41 43 44 51 56 62 66 67 68 69 70 75 7...

result:

wrong answer Incorrect solution!

Test #6:

score: 0
Wrong Answer
time: 44ms
memory: 3596kb

input:

200000 87654321
33240 503
90721 868
64272 858
170928 616
92246 213
50575 59
148252 954
87639 739
328...

output:

100168
100168
1 3 5 6 10 11 13 14 15 16 17 19 23 28 29 32 35 38 39 41 42 45 46 47 48 51 52 53 54 56 ...

result:

wrong answer Incorrect solution!

Test #7:

score: 0
Wrong Answer
time: 55ms
memory: 3596kb

input:

200000 987654321
199051 7573
6332 5631
35615 9816
185684 9227
198894 8029
185684 2173
54203 2887
107...

output:

98978
98978
2 4 7 10 13 20 21 24 26 27 28 30 32 33 34 36 39 41 44 45 46 48 49 52 53 54 55 56 57 58 6...

result:

wrong answer Incorrect solution!

Test #8:

score: 0
Wrong Answer
time: 134ms
memory: 6456kb

input:

444444 998244353
243276 2272
436596 1761
70822 1547
263965 942
280972 2658
87160 421
268504 2945
103...

output:

222615
222615
2 3 4 7 8 11 12 13 16 18 19 20 21 22 23 27 30 31 33 34 35 37 41 43 48 49 52 55 56 57 5...

result:

wrong answer Incorrect solution!

Test #9:

score: 0
Wrong Answer
time: 129ms
memory: 7104kb

input:

500000 999999999
131412 807
486292 804
462352 1139
52896 196
426775 1655
18059 2099
224414 1308
2851...

output:

254580
254580
1 2 3 4 5 6 7 8 11 12 15 18 19 20 22 28 36 37 38 39 40 41 42 46 47 49 50 51 54 59 61 6...

result:

wrong answer Incorrect solution!

Test #10:

score: 0
Wrong Answer
time: 138ms
memory: 7104kb

input:

500000 1000000000
42362 5090
327916 7618
221602 679
295161 1419
69703 4221
108614 6788
210597 6940
2...

output:

231450
231450
1 3 4 5 8 9 10 11 12 14 15 17 20 22 23 28 29 31 32 33 34 36 37 38 39 40 42 45 48 49 50...

result:

wrong answer Incorrect solution!