QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#394197#2536. AkcijaOccDreamer10 17ms66456kbC++142.4kb2024-04-20 10:11:392024-04-20 10:11:41

Judging History

This is the latest submission verdict.

  • [2024-04-20 10:11:41]
  • Judged
  • Verdict: 10
  • Time: 17ms
  • Memory: 66456kb
  • [2024-04-20 10:11:39]
  • Submitted

answer

//OccDreamer
#include<bits/stdc++.h>

#define vc vector
#define db double
#define fi first
#define se second
#define ll long long
#define mk make_pair
#define pb push_back
#define RI register int
#define PI pair<int,int>
#define ull unsigned long long
#define err cerr << "   -_-   " << endl
#define debug cerr << " ------------------- " << endl

#define input(x) freopen(#x".in","r",stdin)
#define output(x) freopen(#x".out","w",stdout)

#define NO puts("No")
#define YES puts("Yes")

//#define OccDreamer
//#define int long long

using namespace std;

namespace IO{
	inline int read(){
		int X=0, W=0; char ch=getchar();
		while(!isdigit(ch)) W|=ch=='-', ch=getchar();
		while(isdigit(ch)) X=(X<<1)+(X<<3)+(ch^48), ch=getchar();
		return W?-X:X;
	}
	inline void write(ll x){
		if(x<0) x=-x, putchar('-');
		if(x>9) write(x/10);
		putchar(x%10+'0');
	}
	inline void sprint(ll x){write(x), putchar(32);}
	inline void eprint(ll x){write(x), putchar(10);}
}using namespace IO;

const int MAXN = 2005;

int n, k, pos;

struct P{
	int w, d;
	inline bool friend operator < (const P &x, const P &y){return x.d<y.d;}
}c[MAXN];

struct dp{
	int num; ll val;	
	inline dp friend operator + (const dp &x, const dp &y){return dp{x.num+y.num,x.val+y.val};}
	inline bool friend operator < (const dp &x, const dp &y){
		return x.num==y.num?x.val<y.val:x.num>y.num;	
	}
}f[MAXN][MAXN];

inline bool comp(dp x, dp y){
	return (x+f[pos+1][x.num])<(y+f[pos+1][y.num]);
}

signed main(){
	n=read(), k=read();
	for(int i=1;i<=n;++i) c[i].w=read(), c[i].d=read();
	sort(c+1,c+1+n);
	for(int i=n;i>=1;--i){
		for(int j=n;j>=0;--j){
			f[i][j]=min(f[i][j],f[i+1][j]);
			if(c[i].d>j) f[i][j]=min(f[i][j],f[i+1][j+1]+dp{1,c[i].w});	
		//cerr << "dp:" << i << ' ' << j << ' ' << f[i][j].num << ' ' << f[i][j].val << endl;
		}
	}
	vc<dp> now; now.pb(dp{0,0});
	for(int i=1;i<=n;++i){
		vc<dp> S;
		//cerr << i << ' ' << now[0].num << ' ' << now[0].val << endl;
		for(auto j:now){
			S.pb(j);
			if(c[i].d>j.num) S.pb(dp{j.num+1,j.val+c[i].w});	
		}
		pos=i+1;
		sort(S.begin(),S.end(),comp);
		int o=min(int(S.size()),k); now.clear();
		for(int j=0;j<o;++j) now.pb(S[j]);
	}
	sort(now.begin(),now.end());
	for(auto i:now) sprint(i.num), eprint(i.val);
	return 0;
}
/*
15 1
1 1
2 3
3 3
4 3
4 3
4 3
9 9
9 9
9 9
9 9
9 9
9 9
9 9
9 9
9 9
*/

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 7ms
memory: 63696kb

input:

1919 1
126746165 1373
126746165 1621
126746165 1157
126746165 1647
126746165 1046
126746165 1626
126746165 813
126746165 1197
126746165 1240
126746165 738
126746165 840
126746165 571
126746165 1712
126746165 109
126746165 1850
126746165 524
126746165 736
126746165 917
126746165 1520
126746165 1559
1...

output:

1893 239930490345

result:

ok single line: '1893 239930490345'

Test #2:

score: 0
Accepted
time: 11ms
memory: 66456kb

input:

2000 1
955444834 1441
955444834 1866
955444834 1
955444834 257
955444834 605
955444834 1999
955444834 294
955444834 473
955444834 185
955444834 794
955444834 373
955444834 776
955444834 692
955444834 1340
955444834 794
955444834 1872
955444834 1078
955444834 1693
955444834 839
955444834 627
95544483...

output:

1966 1878404543644

result:

ok single line: '1966 1878404543644'

Test #3:

score: 0
Accepted
time: 15ms
memory: 61412kb

input:

1837 1
404217733 48
404217733 1712
404217733 1010
404217733 1741
404217733 800
404217733 891
404217733 773
404217733 589
404217733 607
404217733 284
404217733 376
404217733 1284
404217733 1138
404217733 221
404217733 551
404217733 892
404217733 491
404217733 1163
404217733 1142
404217733 1504
404217...

output:

1772 716273822876

result:

ok single line: '1772 716273822876'

Test #4:

score: 0
Accepted
time: 7ms
memory: 60460kb

input:

1814 1
673960138 1285
673960138 1524
673960138 528
673960138 221
673960138 927
673960138 1033
673960138 1620
673960138 793
673960138 1626
673960138 35
673960138 228
673960138 74
673960138 376
673960138 450
673960138 94
673960138 170
673960138 800
673960138 1261
673960138 55
673960138 264
673960138 8...

output:

1795 1209758447710

result:

ok single line: '1795 1209758447710'

Test #5:

score: 0
Accepted
time: 16ms
memory: 65696kb

input:

1981 1
655754816 1085
655754816 343
655754816 1927
655754816 1695
655754816 1417
655754816 1207
655754816 1383
655754816 1184
655754816 429
655754816 281
655754816 1935
655754816 445
655754816 13
655754816 1384
655754816 502
655754816 1790
655754816 862
655754816 1254
655754816 1544
655754816 11
655...

output:

1951 1279377646016

result:

ok single line: '1951 1279377646016'

Test #6:

score: 0
Accepted
time: 4ms
memory: 10756kb

input:

1811 1
934941692 1
934941692 1
934941692 1
934941692 1
934941692 1
934941692 1
934941692 1
934941692 1
934941692 1
934941692 1
934941692 1
934941692 1
934941692 1
934941692 1
934941692 1
934941692 1
934941692 1
934941692 1
934941692 1
934941692 1
934941692 1
934941692 1
934941692 1
934941692 1
93494...

output:

1 934941692

result:

ok single line: '1 934941692'

Test #7:

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

input:

1990 1
356460601 5
356460601 5
356460601 5
356460601 5
356460601 5
356460601 5
356460601 5
356460601 5
356460601 5
356460601 5
356460601 5
356460601 5
356460601 5
356460601 5
356460601 5
356460601 5
356460601 5
356460601 5
356460601 5
356460601 5
356460601 5
356460601 5
356460601 5
356460601 5
35646...

output:

5 1782303005

result:

ok single line: '5 1782303005'

Test #8:

score: 0
Accepted
time: 4ms
memory: 11132kb

input:

1845 1
439788326 4
439788326 2
439788326 3
439788326 5
439788326 4
439788326 3
439788326 5
439788326 2
439788326 3
439788326 2
439788326 3
439788326 1
439788326 1
439788326 3
439788326 2
439788326 1
439788326 3
439788326 3
439788326 4
439788326 5
439788326 5
439788326 2
439788326 2
439788326 2
43978...

output:

5 2198941630

result:

ok single line: '5 2198941630'

Test #9:

score: 0
Accepted
time: 6ms
memory: 11996kb

input:

1802 1
332342588 41
332342588 11
332342588 37
332342588 16
332342588 23
332342588 35
332342588 10
332342588 18
332342588 1
332342588 26
332342588 19
332342588 33
332342588 17
332342588 17
332342588 22
332342588 37
332342588 21
332342588 39
332342588 24
332342588 7
332342588 23
332342588 30
332342588...

output:

42 13958388696

result:

ok single line: '42 13958388696'

Test #10:

score: 0
Accepted
time: 12ms
memory: 38368kb

input:

1873 1
613474075 936
613474075 1
613474075 1
613474075 1
613474075 1
613474075 1
613474075 1
613474075 1
613474075 1
613474075 936
613474075 1
613474075 1
613474075 1
613474075 1
613474075 1
613474075 1
613474075 1
613474075 1
613474075 1
613474075 1
613474075 936
613474075 1
613474075 936
613474075...

output:

923 566236571225

result:

ok single line: '923 566236571225'

Test #11:

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

input:

1 1
22282234 1

output:

1 22282234

result:

ok single line: '1 22282234'

Test #12:

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

input:

2 1
713738007 1
713738007 1

output:

1 713738007

result:

ok single line: '1 713738007'

Test #13:

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

input:

47 1
754775836 35
754775836 42
754775836 13
754775836 5
754775836 26
754775836 35
754775836 1
754775836 17
754775836 44
754775836 2
754775836 43
754775836 14
754775836 2
754775836 4
754775836 45
754775836 35
754775836 7
754775836 18
754775836 14
754775836 32
754775836 29
754775836 47
754775836 45
75...

output:

43 32455360948

result:

ok single line: '43 32455360948'

Subtask #2:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #14:

score: 0
Wrong Answer
time: 17ms
memory: 63724kb

input:

1919 1
126746165 1373
668827372 1621
842598033 1157
119717982 1647
527842278 1046
492815129 1626
917098873 813
346103003 1197
144760418 1240
339840086 738
518170881 840
527423104 571
783646464 1712
77685618 109
74284316 1850
300769843 524
944005181 736
969138120 917
789000286 1520
358649048 1559
189...

output:

1893 934815221331

result:

wrong answer 1st lines differ - expected: '1893 934318516761', found: '1893 934815221331'

Subtask #3:

score: 0
Wrong Answer

Test #27:

score: 0
Wrong Answer
time: 11ms
memory: 63984kb

input:

1919 2
126746165 1373
668827372 1621
842598033 1157
119717982 1647
527842278 1046
492815129 1626
917098873 813
346103003 1197
144760418 1240
339840086 738
518170881 840
527423104 571
783646464 1712
77685618 109
74284316 1850
300769843 524
944005181 736
969138120 917
789000286 1520
358649048 1559
189...

output:

1893 934815221331
1893 934815882531

result:

wrong answer 1st lines differ - expected: '1893 934318516761', found: '1893 934815221331'

Subtask #4:

score: 0
Wrong Answer

Test #40:

score: 10
Accepted
time: 3ms
memory: 3848kb

input:

19 1910
872059530 14
567896598 17
515371564 12
609933207 17
421749461 11
993851818 17
897732743 9
76274388 12
362276371 13
93554371 8
695969254 9
21709341 6
395396341 17
894018749 2
835539456 19
150700500 6
934168428 8
934249073 10
508532761 16

output:

18 9787132136
18 9846734881
18 9846815526
18 9883251211
18 9886965205
18 9908924424
18 10085014700
18 10171050747
18 10213087356
18 10265612390
18 10272451193
18 10359234493
18 10385587613
18 10418707583
18 10630283454
18 10687429583
18 10704709566
18 10759274613
17 8852883063
17 8852963708
17 88893...

result:

ok 1910 lines

Test #41:

score: 0
Accepted
time: 1ms
memory: 3856kb

input:

20 1883
735748837 15
563229302 19
219528931 1
476153920 3
942871419 7
246506664 20
29407208 3
573822564 5
719909005 2
981359250 8
448077622 4
490919926 8
599888635 7
462459069 14
150739326 8
212709849 19
835789078 11
859792932 17
768767483 9
861954306 7

output:

16 7673541346
16 7917296431
16 7935607017
16 7961673088
16 8016524130
16 8042590201
16 8044575726
16 8055011961
16 8059341732
16 8081078032
16 8087418030
16 8125492839
16 8140258845
16 8163980670
16 8168335143
16 8173921420
16 8178746676
16 8179362102
16 8205428173
16 8206822974
16 8260279215
16 828...

result:

ok 1883 lines

Test #42:

score: 0
Accepted
time: 3ms
memory: 3856kb

input:

18 1887
666937376 1
878564254 17
568161994 10
733393578 18
144504113 8
535325978 9
551450306 8
630068459 6
198040795 6
772830221 3
843247194 4
277560202 13
916948987 12
586485641 3
530682767 6
437343456 9
908988480 5
190035793 12

output:

15 7845503699
15 7951396544
15 7988265461
15 8021813517
15 8031848279
15 8058682434
15 8066883614
15 8083007942
15 8087554803
15 8087651153
15 8102265252
15 8124423720
15 8137300587
15 8153424915
15 8158068126
15 8164575279
15 8168006538
15 8180990464
15 8203041873
15 8208158097
15 8219166201
15 822...

result:

ok 1887 lines

Test #43:

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

input:

18 1910
32079340 13
156090008 16
490520938 6
486590052 3
697013119 10
231474055 11
299023445 17
380002679 8
726123174 17
528963793 1
634434113 3
980649968 1
25750352 4
822299809 5
600065005 1
278370194 2
432031451 8
445711516 13

output:

15 6032043925
15 6103145137
15 6137514245
15 6179887986
15 6250989198
15 6388107844
15 6459209056
15 6483730100
15 6631574161
15 6839794019
14 5209744116
14 5280845328
14 5305920751
14 5315214436
14 5335030806
14 5357588177
14 5377021963
14 5406132018
14 5411391071
14 5428689389
14 5440501126
14 545...

result:

ok 1910 lines

Test #44:

score: 0
Accepted
time: 3ms
memory: 3860kb

input:

20 1994
212262730 11
614563104 4
926631931 20
388153742 18
648681729 15
175924270 13
420655750 14
641382438 12
871822259 5
9648746 3
657694080 20
415077754 5
286124047 1
47416497 14
691397676 6
870871304 19
468308899 9
20427661 13
42713839 16
844289622 1

output:

19 8409758456
19 8967924031
18 7483126525
18 7537936197
18 7538887152
18 7718360780
18 7752064376
18 7761076727
18 7768376018
18 7795195352
18 7941449557
18 7989102706
18 7994680702
18 8021604714
18 8041292100
18 8096101772
18 8097052727
18 8123634409
18 8197495726
18 8233834186
18 8276526355
18 831...

result:

ok 1994 lines

Test #45:

score: 0
Accepted
time: 1ms
memory: 3636kb

input:

18 19
934941692 1
892631472 1
221963002 1
390559518 1
986350949 1
524427523 1
96444602 1
656854970 1
425992688 1
822387303 1
380252829 1
556647080 1
522523573 1
318687106 1
201564132 1
867885853 1
86695278 1
697351162 1

output:

1 86695278
1 96444602
1 201564132
1 221963002
1 318687106
1 380252829
1 390559518
1 425992688
1 522523573
1 524427523
1 556647080
1 656854970
1 697351162
1 822387303
1 867885853
1 892631472
1 934941692
1 986350949
0 0

result:

ok 19 lines

Test #46:

score: -10
Wrong Answer
time: 4ms
memory: 3856kb

input:

20 1979
356460601 5
224848374 5
881788059 5
68992860 5
44771412 5
397401947 5
115595477 5
638932295 5
106806913 5
568887059 5
653343572 5
449691055 5
569508871 5
360141436 5
518437673 5
668425148 5
886061724 5
470450770 5
810689001 5
790147395 5

output:

5 692627263
5 696308098
5 733568609
5 785857717
5 806617432
5 854604335
5 905053721
5 905675533
5 937173222
5 945961786
5 974433733
5 975098957
5 978114568
5 983222297
5 983775839
5 986903132
5 989510234
5 1004591810
5 1007997287
5 1021036350
5 1024717185
5 1026722841
5 1030403676
5 1035511405
5 103...

result:

wrong answer 1st lines differ - expected: '5 561015036', found: '5 692627263'

Subtask #5:

score: 0
Wrong Answer

Test #53:

score: 0
Wrong Answer
time: 1ms
memory: 4152kb

input:

96 96
390531470 69
349016804 82
612244127 58
41258987 83
470944790 53
681046579 82
109569778 41
700928268 60
224279712 63
681889278 37
173204769 43
701269722 29
624757038 86
271969787 6
444924884 93
500697380 27
509702566 37
262449977 46
669488879 77
170692294 78
362932916 51
118514404 47
724509790 ...

output:

94 42881894279
94 42885031902
94 42886655954
94 42893770642
94 42895394694
94 42898532317
94 42925575942
94 42928026677
94 42934314682
94 42936765417
94 42937452305
94 42939076357
94 42939903040
94 42941527092
94 42942082928
94 42950821668
94 42953959291
94 42955583343
94 42966521813
94 42971243241
...

result:

wrong answer 23rd lines differ - expected: '94 42979981981', found: '94 42980447080'

Subtask #6:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%