QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#616971#3998. The ProfiteerlgvcTL 994ms25872kbC++231.4kb2024-10-06 13:17:162024-10-06 13:17:20

Judging History

你现在查看的是最新测评结果

  • [2024-10-06 13:17:20]
  • 评测
  • 测评结果:TL
  • 用时:994ms
  • 内存:25872kb
  • [2024-10-06 13:17:16]
  • 提交

answer

#include <bits/stdc++.h>
int N,K,E,v[200009],a[200009],b[200009],dp[200009];
std::multiset<int> ss[200009];
void ins(int a,int b) {
	ss[a].insert(-b);
}
void era(int a,int b) {
	auto it=ss[a].find(-b);
	ss[a].erase(it);
}
struct n_t{
	int a,b;
} tp[200009];
bool fl=0;unsigned long long la=1145141919;
bool tr(int l,int r) {
	unsigned long long ans=0;
	int qq=0;
	for(int i=1;i<=K;i++) {
		int num=0;
		for(auto it=ss[i].begin();it!=ss[i].end();it++) {
			num++;
			if(num*i>K) break;
			int c=i;
			int xx=-(*it);
			tp[++qq]=(n_t){i,xx};
			ans=(ans*1377+i);
			ans=(ans*1377+xx);
		}
	}
	if(ans==la) {
		return fl;
	}
	la=ans;
	memset(dp,0,sizeof(dp[0])*(K+5));
	for(int i=1;i<=qq;i++) {
		for(int j=K;j>=tp[i].a;j--) {
			dp[j]=std::max(dp[j],dp[j-tp[i].a]+tp[i].b);
		}
	}
	long long su=0;
	for(int i=1;i<=K;i++) su+=dp[i];
	if(su>1ll*E*K) return fl=1;
	return fl=0;
}
signed main(void) {
	scanf("%d %d %d",&N,&K,&E);
	for(int i=1;i<=N;i++) {
		scanf("%d %d %d",&v[i],&a[i],&b[i]);
		ins(a[i],v[i]);
	}
	int l=0;
	long long ans=0;
	for(int i=1;i<=N;i++) {
		if(l>=i-1&&i>1) {
			era(b[i-1],v[i-1]);
			ins(a[i-1],v[i-1]);
		} else {
			l=i-1;
		}
		while(l<=N) {
			if(tr(i,l)) {
				l++;
				if(l<=N) {
					era(a[l],v[l]);
					ins(b[l],v[l]);
				}
			}else break;
		}
		ans+=N-std::max(l,i)+1;
	}
	printf("%lld",ans);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 16084kb

input:

4 5 3
3 2 4
1 2 3
2 1 2
3 1 3

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 0ms
memory: 16204kb

input:

4 5 4
3 2 4
1 2 3
2 1 2
3 1 3

output:

3

result:

ok single line: '3'

Test #3:

score: 0
Accepted
time: 2ms
memory: 16148kb

input:

4 5 5
3 2 4
1 2 3
2 1 2
3 1 3

output:

7

result:

ok single line: '7'

Test #4:

score: 0
Accepted
time: 709ms
memory: 25724kb

input:

200000 50 23333
2620 5 21
8192 17 34
6713 38 46
6687 13 42
390 9 13
4192 7 37
7898 17 21
1471 16 45
3579 22 40
9628 8 23
7164 28 45
3669 14 31
5549 29 35
4670 30 39
5811 15 20
4162 18 29
7590 29 41
7786 23 35
383 9 40
5576 39 46
5586 4 9
1110 14 33
8568 4 6
8548 39 42
9133 10 42
6679 22 39
8353 33 3...

output:

0

result:

ok single line: '0'

Test #5:

score: 0
Accepted
time: 625ms
memory: 25792kb

input:

200000 50 233332
8019 18 20
3111 27 40
2015 16 47
6491 17 18
1224 30 38
428 23 34
7521 4 41
7252 6 33
4121 32 45
4230 18 35
1605 21 42
9489 17 25
3704 35 45
6202 8 22
6493 1 5
3041 14 46
4509 23 43
9646 11 48
5294 19 27
3562 19 40
9408 30 47
1751 21 29
4053 4 27
5596 32 49
8609 13 29
1686 4 31
3588 ...

output:

17523021

result:

ok single line: '17523021'

Test #6:

score: 0
Accepted
time: 269ms
memory: 25724kb

input:

200000 50 2333331
7420 30 44
8652 22 28
5418 8 21
9825 3 8
4257 21 40
9962 6 16
3370 18 41
2192 37 41
231 8 18
7764 3 41
3455 9 18
1159 8 46
9775 9 42
4400 21 43
4593 10 22
712 7 22
2067 21 27
9618 9 35
8008 13 38
114 4 31
4503 39 49
4661 14 41
4837 15 35
1371 12 16
9568 21 48
8934 16 34
870 4 35
83...

output:

20000100000

result:

ok single line: '20000100000'

Test #7:

score: 0
Accepted
time: 616ms
memory: 25872kb

input:

200000 50 253330
4837 37 46
2436 11 48
2043 24 50
3544 27 40
1499 21 43
9009 36 46
9172 11 17
585 29 44
6379 4 28
6630 25 37
9230 24 35
5736 23 50
4324 34 50
4624 23 47
9933 3 12
577 12 18
4411 24 32
8750 42 48
4808 21 34
3904 7 17
5979 41 48
2838 29 40
8682 25 46
4026 11 19
8371 8 42
4550 6 24
1546...

output:

2513593675

result:

ok single line: '2513593675'

Test #8:

score: 0
Accepted
time: 505ms
memory: 25816kb

input:

200000 50 193334
8521 14 21
3902 5 6
2949 4 41
1034 10 36
6156 16 36
9432 35 37
3752 25 37
9668 5 9
3194 43 45
9849 1 26
1582 6 10
9920 20 50
994 34 50
9510 12 38
4513 18 31
6294 3 48
4949 9 18
2348 10 49
5492 19 46
2265 3 37
67 20 40
8752 1 5
4610 27 41
7344 27 39
7767 16 29
921 7 16
1853 23 44
936...

output:

1432887

result:

ok single line: '1432887'

Test #9:

score: 0
Accepted
time: 448ms
memory: 20828kb

input:

100000 100 304560
2347 27 64
3715 15 62
6005 16 86
9856 21 55
1347 5 89
9403 25 33
3889 36 74
554 18 95
5218 27 72
3282 2 68
4955 48 83
3478 7 36
3917 34 99
2117 24 41
9764 35 52
7991 81 94
8026 55 69
7755 27 44
3568 18 50
1968 36 57
7992 63 67
7760 4 55
6938 4 53
722 89 99
1111 47 66
5995 71 80
510...

output:

6114559

result:

ok single line: '6114559'

Test #10:

score: 0
Accepted
time: 459ms
memory: 20836kb

input:

100000 100 404561
3114 87 96
4983 68 99
4734 9 65
3721 49 79
7965 40 74
4463 33 81
731 7 61
9048 36 50
6891 40 68
4236 2 43
5436 6 45
1643 64 85
6889 5 95
5673 21 42
2119 57 70
2940 14 98
5620 59 67
8567 76 90
7543 81 99
5576 4 51
7281 4 100
2485 55 75
9357 6 45
4345 33 62
2261 7 26
2371 4 44
9758 5...

output:

29508633

result:

ok single line: '29508633'

Test #11:

score: 0
Accepted
time: 490ms
memory: 21508kb

input:

100000 100 454562
4294 4 37
7975 12 19
4648 1 83
674 41 84
8184 33 57
9088 56 79
2734 56 60
411 11 52
267 20 41
3503 75 86
6921 24 90
1255 49 90
1841 25 27
7767 86 97
9921 25 26
3063 23 44
9237 10 32
4991 7 87
969 36 100
5989 21 87
1420 45 73
780 7 26
6408 85 90
33 31 41
9767 36 89
7666 16 35
3725 1...

output:

160913569

result:

ok single line: '160913569'

Test #12:

score: 0
Accepted
time: 773ms
memory: 18732kb

input:

50000 200 604563
7628 31 102
3694 47 127
4931 101 187
332 7 146
800 131 143
6750 50 136
3718 88 108
5113 36 188
6565 16 49
7739 66 159
215 97 125
1184 90 150
6960 41 173
2281 18 66
3221 144 155
3431 12 162
4191 59 164
8530 28 30
2720 103 196
1176 171 194
2328 124 200
8209 62 114
2606 6 168
1201 120 ...

output:

97043020

result:

ok single line: '97043020'

Test #13:

score: 0
Accepted
time: 919ms
memory: 18752kb

input:

50000 200 804564
2147 132 170
2582 142 185
2492 29 44
4085 50 81
2749 40 115
7068 3 49
5096 72 127
2097 71 122
6697 130 145
6755 141 163
6197 66 130
3397 136 167
7546 71 156
7798 153 169
655 91 94
9498 62 117
7881 71 112
582 67 100
2382 6 189
7366 101 116
2254 56 138
4321 68 125
1601 44 54
2186 65 1...

output:

566251550

result:

ok single line: '566251550'

Test #14:

score: 0
Accepted
time: 994ms
memory: 17204kb

input:

50000 200 824565
2301 142 166
3523 60 153
3438 18 182
4052 42 116
6084 106 166
5687 45 55
2362 34 57
891 171 177
4412 18 49
3142 99 186
9489 86 103
7153 32 90
8357 35 115
6666 161 181
9346 160 196
6328 60 119
3756 16 135
990 130 150
4038 113 128
3608 69 127
8803 119 193
7508 100 141
2918 96 179
5466...

output:

718514472

result:

ok single line: '718514472'

Test #15:

score: 0
Accepted
time: 918ms
memory: 17232kb

input:

50000 200 844566
3943 49 169
1142 177 181
5370 77 91
9254 48 141
1986 87 196
8256 21 188
4440 116 174
6575 5 126
6139 8 67
5192 44 66
3795 51 60
2574 93 139
9861 46 164
3735 46 149
4388 19 46
3578 110 138
6011 25 99
9446 145 189
9215 22 156
9708 119 128
4207 28 172
1229 19 121
4672 161 174
938 35 60...

output:

832753831

result:

ok single line: '832753831'

Test #16:

score: 0
Accepted
time: 352ms
memory: 18376kb

input:

50000 200 864567
1496 192 200
501 22 137
8461 144 151
6841 56 92
4249 5 170
8990 100 155
8686 54 66
3745 144 175
406 127 179
8669 94 108
6146 141 187
1715 178 188
9270 20 160
1541 12 19
9499 66 132
2513 124 152
6228 83 126
8232 106 133
9816 101 197
7403 28 98
4128 14 113
2935 162 190
9541 78 166
773...

output:

1250025000

result:

ok single line: '1250025000'

Test #17:

score: -100
Time Limit Exceeded

input:

20000 500 604507
8220 251 441
473 267 330
7866 43 172
1675 178 390
7373 216 466
5691 122 274
4101 219 461
7195 406 475
3120 229 462
9594 164 276
8539 4 337
4490 98 498
6378 297 375
2771 40 144
5832 127 372
7877 6 438
9080 140 247
3343 56 354
4402 329 451
7275 56 90
8068 32 47
1412 143 373
9605 17 41...

output:


result: