QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#394022#2536. Akcijalfxxx#30 51ms70980kbC++172.1kb2024-04-19 20:58:302024-07-04 03:36:42

Judging History

This is the latest submission verdict.

  • [2024-07-04 03:36:42]
  • Judged
  • Verdict: 30
  • Time: 51ms
  • Memory: 70980kb
  • [2024-04-19 20:58:30]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
bool be;
constexpr int N = 2005;
int n, k;
struct Node {
	int w, d;
}a[N];
struct node {
	ll val;
	vector<int>v;
	inline bool operator < (node c) const {
		if (v.size() != c.v.size()) return v.size() < c.v.size();
		return val > c.val;
	}
}b;
void getv()
{
	priority_queue<pii>q;
	for (int i = 1; i <= n; ++i) {
		if (q.size() < a[i].d) {
			q.emplace(a[i].w, i);
		} else {
			if (q.top().first > a[i].w) {
				q.pop();
				q.emplace(a[i].w, i);
			}
		}
	}
	while (!q.empty()) {
		b.v.emplace_back(q.top().second);
		b.val += q.top().first;
		q.pop();
	}
}
void solve()
{
	priority_queue<node>q;
	set<vector<int>>se;
	q.emplace(b);
	se.emplace(b.v);
	while (!q.empty() && k--) {
		node c = q.top();
		q.pop();
		cout << c.v.size() << ' ' << c.val << '\n';
		for (int i = 0; i < c.v.size(); ++i) {
			if (c.v[i] < n && a[c.v[i]].d == a[c.v[i] + 1].d && (i + 1 == c.v.size() || c.v[i] + 1 < c.v[i + 1])) {
				c.val -= a[c.v[i]].w;
				++c.v[i];
				c.val += a[c.v[i]].w;
				if (se.emplace(c.v).second) {
					q.emplace(c);
				}
				c.val -= a[c.v[i]].w;
				--c.v[i];
				c.val += a[c.v[i]].w;
			}
		}
		for (int i = 0; i < c.v.size(); ++i) {
			int id = c.v[i], w = a[c.v[i]].w;
			c.val -= w;
			c.v.erase(c.v.begin() + i);
			if (se.emplace(c.v).second) {
				q.emplace(c);
			}
			c.v.emplace(c.v.begin() + i, id);
			c.val += w;
		}
	}
	while (k-- > 0) cout << "0 0\n";
}
bool en;
int main() {
	cerr << (&be - &en) / 1024.0 / 1024 << " MB\n--------------------------------" << endl;
#ifdef IAKIOI
	freopen("in.in", "r", stdin);
//	freopen("out.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i].w >> a[i].d;
	}
	sort(a + 1, a + 1 + n, [](Node a, Node b) {
		if (a.d != b.d) return a.d < b.d;
		return a.w < b.w;
	});
	getv();
	solve();
	return 0;
}

详细

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 29ms
memory: 32004kb

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: 30ms
memory: 34292kb

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: 23ms
memory: 28732kb

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: 16ms
memory: 29356kb

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: 29ms
memory: 33808kb

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: 1ms
memory: 3908kb

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: 1ms
memory: 3968kb

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: 1ms
memory: 4028kb

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: 1ms
memory: 3820kb

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: 8ms
memory: 10652kb

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: 1ms
memory: 4028kb

input:

1 1
22282234 1

output:

1 22282234

result:

ok single line: '1 22282234'

Test #12:

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

input:

2 1
713738007 1
713738007 1

output:

1 713738007

result:

ok single line: '1 713738007'

Test #13:

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

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: 20
Accepted

Dependency #1:

100%
Accepted

Test #14:

score: 20
Accepted
time: 15ms
memory: 37184kb

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 934318516761

result:

ok single line: '1893 934318516761'

Test #15:

score: 0
Accepted
time: 19ms
memory: 39484kb

input:

2000 1
955444834 1441
87345570 1866
807140020 1
452949476 257
818869981 605
161621665 1999
504099265 294
598031629 473
226306660 185
713394097 794
44533525 373
345561041 776
361821668 692
39849424 1340
545901297 794
745021573 1872
939642412 1078
719782870 1693
269723920 839
462215558 627
695935199 1...

output:

1966 990213629004

result:

ok single line: '1966 990213629004'

Test #16:

score: 0
Accepted
time: 26ms
memory: 33256kb

input:

1837 1
404217733 48
760111913 1712
635231398 1010
112054506 1741
297775642 800
988252633 891
547492872 773
447889215 589
184474212 607
98312137 284
514971126 376
705702660 1284
428618641 1138
284561840 221
229651857 551
239129770 892
679610908 491
661999745 1163
564888989 1142
606821489 1504
2943314...

output:

1772 845948441583

result:

ok single line: '1772 845948441583'

Test #17:

score: 0
Accepted
time: 23ms
memory: 33596kb

input:

1814 1
673960138 1285
81028746 1524
421252653 528
23986853 221
239140624 927
891249203 1033
962614277 1620
792355265 793
628225416 1626
970645055 35
385299960 228
737128556 74
351438607 376
255496258 450
185170885 94
93888187 170
198693111 800
844239992 1261
716879039 55
162912511 264
307460806 829
...

output:

1795 883197439380

result:

ok single line: '1795 883197439380'

Test #18:

score: 0
Accepted
time: 25ms
memory: 38764kb

input:

1981 1
655754816 1085
678728908 343
133130441 1927
373977459 1695
938792353 1417
905077842 1207
24418879 1383
525819604 1184
807011577 429
558345553 281
160730060 1935
933294628 445
321504227 13
231009700 1384
362825113 502
450254037 1790
410951067 862
732893408 1254
664094189 1544
36187258 11
72576...

output:

1951 945978796419

result:

ok single line: '1951 945978796419'

Test #19:

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

input:

1811 1
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
792894229 1
879902215 1
473852172 1
260425780 1
169983923 1
820738833 1
9448251...

output:

1 411136

result:

ok single line: '1 411136'

Test #20:

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

input:

1990 1
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
418733089 5
556237364 5
257498102 5
621544695 5
1670904...

output:

5 6765520

result:

ok single line: '5 6765520'

Test #21:

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

input:

1845 1
439788326 4
290322352 2
986205736 3
710314349 5
685726300 4
853875260 3
971736329 5
438979736 2
886818995 3
172808191 2
420841453 3
510881405 1
431215518 1
199291335 3
467841446 2
683750115 1
257564895 3
202281694 3
826348885 4
385400539 5
217140246 5
456942122 2
41496387 2
829740419 2
751741...

output:

5 6933249

result:

ok single line: '5 6933249'

Test #22:

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

input:

1802 1
332342588 41
970441845 11
719381653 37
922576512 16
177275034 23
488255662 35
253050193 10
620786108 18
709863734 1
807506164 26
624934371 19
657679271 33
968188704 17
636677279 17
733619521 22
326275757 37
349557250 21
712026273 39
248279211 24
165404787 7
373691690 23
404033360 30
769815056...

output:

42 500827803

result:

ok single line: '42 500827803'

Test #23:

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

input:

1873 1
613474075 936
191550631 1
565168039 1
940922606 1
723793989 1
936250872 1
651398486 1
818818788 1
554633771 1
275490534 936
290775497 1
843102091 1
650604084 1
499561988 1
758111235 1
459142648 1
400436681 1
730320150 1
756878960 1
964498323 1
145557078 936
896291394 1
759694823 936
850781148...

output:

923 459262234401

result:

ok single line: '923 459262234401'

Test #24:

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

input:

1 1
22282234 1

output:

1 22282234

result:

ok single line: '1 22282234'

Test #25:

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

input:

2 1
713738007 1
497377109 1

output:

1 497377109

result:

ok single line: '1 497377109'

Test #26:

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

input:

47 1
754775836 35
720966791 42
536811951 13
505979127 5
217605295 26
876354039 35
675775060 1
310941447 17
154939582 44
787188025 2
56856271 43
754435010 14
176488825 2
351725042 4
930103697 45
359325051 35
40188748 7
233690931 18
670639934 14
185587886 32
824070707 29
130571086 47
885846939 45
5856...

output:

43 19340489859

result:

ok single line: '43 19340489859'

Subtask #3:

score: 0
Wrong Answer

Test #27:

score: 0
Wrong Answer
time: 51ms
memory: 70980kb

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 934318516761
1893 934319502884

result:

wrong answer 2nd lines differ - expected: '1893 934319294852', found: '1893 934319502884'

Subtask #4:

score: 0
Wrong Answer

Test #40:

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

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 9916123295
18 9988895625
18 10117886784
18 10627746193
18 10756737352
18 10829509682
18 10958500841
17 8852883063
17 8852963708
17 8889399393
17 8893113387
17 8915072606
17 8951592680
17 8981874222
17 8981954867
17 9018390552
17 9022104546
17 9044063765
17 9054646552
17 9054727197
1...

result:

wrong answer 2nd lines differ - expected: '18 9846734881', found: '18 9916123295'

Subtask #5:

score: 0
Wrong Answer

Test #53:

score: 0
Wrong Answer
time: 7ms
memory: 11544kb

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 42903395362
94 42957163837
94 42978664920
94 43054080991
94 43075582074
94 43129350549
94 43137455822
94 43150851632
94 43158956905
94 43177968527
94 43199469610
94 43201595730
94 43212725380
94 43213924054
94 43223096813
94 43234226463
94 43235425137
94 43253238085
94 43274739168
...

result:

wrong answer 2nd lines differ - expected: '94 42885031902', found: '94 42903395362'

Subtask #6:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

0%