QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#55215#1753. Crooked Dealingabdelrahman001#AC ✓7ms4128kbC++940b2022-10-12 18:56:562022-10-12 18:56:59

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-12 18:56:59]
  • Judged
  • Verdict: AC
  • Time: 7ms
  • Memory: 4128kb
  • [2022-10-12 18:56:56]
  • Submitted

answer

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
const int N = 1e3 + 5;
int n, h;
map<int, int> mp;
priority_queue<pair<int, int>> q;
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> h;
    for(int i = 0;i < n;i++) {
		int x;
		cin >> x;
		mp[x]++;
	}
	for(auto i : mp)
		q.push({i.second, i.first});
	bool ok = false;
	while(1) {
		vector<int> tmp;
		for(int i = 0;i < h && q.size();i++) {
			auto cur = q.top();
			q.pop();
			tmp.push_back(cur.second);
		}
		if(tmp.size() < h)
			break;
		ok = true;
		for(auto i : tmp) {
			cout << i << " ";
			mp[i]--;
			if(mp[i])
				q.push({mp[i], i});
		}
		cout << '\n';
	}
	if(!ok)
		cout << "impossible";
    return 0;
}


詳細信息

Test #1:

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

input:

5 1
100 100 100 99 99

output:

100 
100 
99 
100 
99 

result:

ok Good Job

Test #2:

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

input:

3779 12
7986 8935 4256 9944 9331 3723 6502 786 7065 7034 10747 3375 4036 5541 3222 6012 4024 10857 9983 8474 6217 9459 7015 10729 7329 10530 10319 2021 51 3244 1842 1674 7603 966 7633 2037 4478 6177 9217 8625 9457 1561 1353 417 11104 1783 5316 5967 522 6932 9456 3698 11249 739 7449 4991 2549 4106 57...

output:

5308 11253 10919 10670 10479 10441 10109 9698 9345 8753 8651 8596 
8139 8109 8073 7796 6972 6915 6806 6774 6390 6352 5685 5486 
5308 4856 4802 4246 3927 3767 3467 3257 2937 2787 2356 2179 
1194 902 803 11319 11270 11261 11253 11222 11186 11178 11168 11156 
11103 11082 11075 11047 11046 11015 10980 1...

result:

ok Good Job

Test #3:

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

input:

2500 40
3322 1903 2727 698 2388 7126 3376 5179 3963 6301 2610 763 6844 6492 179 1283 3344 114 351 6363 73 127 7371 2457 5024 2697 207 6129 5815 591 2516 241 5245 215 5734 5823 2323 276 5327 2887 5386 2329 3494 7269 4852 1497 627 2175 7229 2631 460 698 6504 7070 5220 783 4407 7415 4372 6032 5891 1732...

output:

351 4872 4823 1369 6961 6683 6545 6231 5889 5404 4920 4786 4698 4523 4037 3923 3878 3812 3607 3405 3260 3156 3139 2984 2977 2903 2485 2421 2329 2115 2025 1580 1545 1452 1219 487 7495 7484 7462 7447 
351 4872 4823 1369 7407 7399 7372 7329 7299 7288 7229 7216 7167 7108 7096 7085 7084 7040 6998 6961 69...

result:

ok Good Job

Test #4:

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

input:

1221 29
665 2635 1289 1132 2981 2095 1197 1142 1588 219 2740 3318 1719 888 2797 2974 1967 266 781 3478 1726 731 1271 2597 2540 2895 531 1671 2001 3193 1863 3358 2667 3561 3135 1367 823 1937 2226 33 2206 1771 2976 3303 1152 886 2558 197 3230 330 1057 3150 2719 3004 2692 2816 3482 2253 2417 3003 795 2...

output:

687 639 3383 3358 2981 2719 2497 2292 2224 2002 2000 1640 1274 1178 1132 274 239 3655 3651 3644 3595 3561 3523 3522 3513 3427 3422 3404 3393 
687 639 3383 3364 3358 3357 3316 3134 3110 3108 3077 3063 3062 3046 3045 3035 2981 2977 2952 2949 2945 2927 2911 2871 2850 2846 2779 2761 2749 
2719 2698 2692...

result:

ok Good Job

Test #5:

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

input:

9842 17
27156 5454 10038 15502 9129 5710 6001 27543 9999 8245 4371 20950 756 18278 14853 13364 18536 3840 11198 1484 27530 11284 20991 2660 21157 6521 7745 2807 9364 19609 20120 23649 22347 27031 27956 28634 4110 610 14902 18691 14351 19377 4685 24627 28985 8384 9235 24134 23608 24484 15227 18500 18...

output:

27981 26191 23328 20903 20244 19301 12396 9616 8751 6417 5542 3356 2216 29199 29013 28789 28402 
28344 28044 27981 27575 27314 26941 26939 26884 26630 26243 26218 26191 26118 25854 25667 25531 25518 
25163 24711 24113 23886 23525 23361 23328 22953 22884 22844 22754 22668 22420 22359 21654 21511 2146...

result:

ok Good Job

Test #6:

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

input:

8563 45
16908 16704 8430 19035 20669 20938 2051 14232 6263 12816 14080 13191 14956 25582 6234 2400 18464 4817 14014 3884 10115 14509 1927 12109 19008 16737 9755 18857 2262 11735 21949 17607 20181 22066 976 14553 1386 13168 10326 6606 9505 21300 12976 19692 16674 8379 23824 14927 18429 14604 19084 10...

output:

21077 19400 15785 7815 25502 25189 24919 24812 24631 24283 23889 23806 23722 23332 23189 23117 22637 22536 22381 22317 22213 21687 21536 21515 21243 21115 21027 20913 20724 20665 20186 20017 19876 19854 19629 19155 19138 18857 18654 18412 18334 18163 18103 17720 17469 
21077 19400 17428 16953 16873 ...

result:

ok Good Job

Test #7:

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

input:

7283 33
8666 2529 6912 20909 6554 9542 20897 3828 3255 15698 20715 6935 3031 8141 21462 16042 17692 5353 15551 5509 18683 16330 9594 18629 16677 1797 10861 8150 18767 5451 599 12451 17793 17532 2823 3566 21165 100 6537 19254 5549 44 18606 15273 6915 8049 11843 7533 13879 6724 21196 3500 8018 9879 18...

output:

21070 16313 12206 7792 7191 6011 4429 2468 1421 21675 21501 21429 20882 20756 20720 20627 20520 20111 19905 19741 19365 19245 19242 19230 18883 18767 18692 18629 18492 18445 18428 18342 18172 
21070 18123 18024 17983 17508 17461 17207 16745 16341 16313 16185 15901 15515 15508 15462 15213 15159 14994...

result:

ok Good Job

Test #8:

score: 0
Accepted
time: 5ms
memory: 3904kb

input:

6004 21
2433 10470 5485 3115 14326 1052 15005 14344 975 16897 6271 2186 12524 13498 13003 6755 16223 5448 15814 6360 5700 16751 14467 4213 14169 9239 11068 216 11345 760 3610 8183 15186 13435 3969 13688 15913 8943 3538 9102 2485 3151 3566 11374 17722 7396 2822 1954 9962 847 3554 16697 4357 5936 1603...

output:

10803 9159 17950 17695 17690 17162 17115 17108 16298 16221 16185 16122 15867 15780 15766 15593 15255 14720 14673 14065 13309 
12918 12905 12559 12172 11816 11759 11642 11589 11233 10803 10719 10692 10252 10153 10147 9987 9636 9159 9085 8904 8888 
8438 8417 8136 8043 7913 7818 7631 7594 7514 7414 732...

result:

ok Good Job

Test #9:

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

input:

4725 10
12382 664 4149 5513 4122 9640 10059 5919 13598 2236 10606 13116 3570 1788 6542 225 14057 5102 627 6436 11026 1597 2371 8720 11482 13376 10375 9227 5681 11834 5294 4801 12359 9772 4416 5056 11315 14012 1328 1835 311 4930 7717 7994 9233 6419 10933 12363 6675 11146 6018 9834 1657 2934 13173 126...

output:

12515 11343 6585 3849 3510 2250 1623 14165 14057 13986 
13819 13576 13522 13477 13443 13116 12976 12778 12753 12650 
12545 12515 12359 12193 11786 11369 11351 11343 11194 11027 
10963 10866 10767 10610 10594 10186 10149 10114 9862 9832 
9805 9590 9552 9389 8992 8937 8718 8680 8559 8277 
7994 7965 77...

result:

ok Good Job

Test #10:

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

input:

3446 38
6327 5297 2904 6253 8128 3119 6061 401 8937 3901 1533 7539 8358 5199 2079 6789 854 4315 2176 5738 2473 3052 5493 10301 8616 3870 8780 2997 1775 6488 5649 2307 9311 6542 4164 9856 7371 4967 10245 7790 9365 5383 9210 5132 3296 5118 3989 6573 4019 5433 6738 4762 10254 872 10010 7792 1313 3863 1...

output:

2822 6704 4000 3709 10274 9856 9406 9263 9179 8982 8963 8918 8839 8577 8533 8403 7696 7649 7364 7329 6828 6285 6031 5989 5812 5811 5607 5512 5336 5323 4656 3162 3112 2109 1874 1816 1460 1334 
2822 6704 4000 3709 1324 1138 917 161 10334 10284 10274 10244 10235 10210 10203 10197 10176 10160 10152 1012...

result:

ok Good Job

Test #11:

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

input:

2167 26
2278 6357 1750 5337 1831 6003 3009 4290 5004 3881 3565 3467 2373 5719 6116 1934 1129 3088 2449 4265 4554 3107 5822 2455 5570 5233 6285 6039 6128 2732 4677 700 6042 3747 3211 3576 4081 6322 5774 2455 5135 4509 1543 2788 6411 3493 4 2598 1993 1722 5714 1479 5635 6253 47 2717 3184 1 1281 6037 1...

output:

6463 6421 6395 6253 6095 5645 5570 5374 4064 3958 3768 3537 3295 3198 3184 2836 2664 2517 2455 2268 2063 1934 1543 1109 969 707 
487 472 87 6463 6461 6421 6396 6395 6344 6342 6332 6280 6253 6247 6215 6195 6193 6184 6152 6151 6116 6095 6092 6069 6059 6046 
6042 6016 6004 6003 5999 5927 5916 5909 5903...

result:

ok Good Job

Test #12:

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

input:

888 14
237 1182 686 98 2070 1452 905 749 1798 2176 2527 899 2455 684 1813 2500 705 1419 1447 2017 432 1760 692 2022 2345 628 224 1513 1901 568 2378 2643 2553 1385 1559 391 1446 1237 2093 5 1795 2309 1556 963 1742 1544 1639 435 598 11 283 2649 1976 2236 123 219 2272 1670 730 2515 1782 454 2113 2234 1...

output:

2571 2422 2075 1489 1211 1160 825 823 812 692 174 12 2662 2643 
2619 2599 2571 2515 2492 2454 2453 2440 2433 2422 2378 2359 2320 2319 
2309 2297 2296 2229 2183 2163 2142 2139 2105 2075 2042 2026 2022 2020 
2018 1995 1952 1941 1926 1919 1911 1907 1878 1836 1832 1813 1783 1746 
1719 1669 1664 1662 165...

result:

ok Good Job

Test #13:

score: 0
Accepted
time: 5ms
memory: 4072kb

input:

9509 42
23600 25927 7002 7210 7769 4756 6161 25739 16545 1033 9936 4025 13639 18064 11980 16518 10142 16826 20230 24471 17778 24050 17789 3999 25772 19008 5746 5899 13817 159 1866 25003 28152 13212 19292 21210 13043 27280 19475 17852 15912 1121 26536 8379 9157 17736 6554 26441 4058 21205 9508 21708 ...

output:

2962 563 27036 23536 19021 17429 16230 16107 11888 11434 9425 9334 8170 7019 28264 28104 27717 27642 27139 27122 27084 27072 26232 26050 25495 24864 24578 24529 24302 24236 24041 23758 23064 23002 22848 22703 22593 22063 21933 21674 21129 20910 
2962 563 27036 23536 20590 20325 20203 20111 20089 199...

result:

ok Good Job

Test #14:

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

input:

8230 30
13968 9244 5768 11573 18956 19465 2286 12924 11978 6316 18477 23333 856 247 3940 5428 11023 15981 21613 23672 2088 634 24385 12874 22883 2395 7872 20881 6302 19709 5887 18787 386 10039 18948 8400 9184 11067 14318 6170 10907 5239 6830 5585 24404 16393 20847 17050 1484 11915 13839 13031 12137 ...

output:

24106 6686 23383 18119 17944 7212 6100 5381 2284 24184 23804 23767 23642 23207 22984 22485 22247 22080 21920 21785 21772 21748 21163 21116 20847 20620 20185 20133 20073 20007 
24106 6686 23383 19779 19728 19704 19633 19330 19312 19084 18787 18660 18553 18486 18119 17989 17944 17905 17869 17659 17141...

result:

ok Good Job

Test #15:

score: 0
Accepted
time: 5ms
memory: 3960kb

input:

6951 19
6344 17515 4626 14278 5487 8551 20210 3016 8139 9914 3094 15618 12329 8065 18751 17947 11207 14696 868 1245 11384 4343 7335 18824 19814 11004 9096 10108 545 12323 8579 13457 925 7300 17905 19538 5979 19606 9950 18225 6792 8030 12993 3308 13676 14726 9571 9473 20393 4626 16426 6143 7644 9829 ...

output:

18918 9222 7353 6385 5965 5712 4580 4374 669 20399 20367 19756 19061 19040 18465 18209 18207 17911 17733 
18918 17602 17475 17385 17306 17256 17169 17096 16566 16426 16091 15945 15785 15524 15386 15151 14984 14799 14373 
14196 13790 13641 13162 12951 12829 12727 12603 12491 12275 11906 11854 11816 1...

result:

ok Good Job

Test #16:

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

input:

5672 47
726 5197 3574 15326 12907 540 14392 13031 5028 11827 9332 9409 2515 12992 10870 8533 10693 12970 3537 2734 124 6652 12180 4832 16566 16308 9420 2105 13563 6528 9945 9015 1244 4995 16162 9080 3428 7354 6371 8475 3568 9494 16497 1550 5501 12735 1252 3709 15243 16354 254 1045 4109 5934 3431 125...

output:

16726 15057 14832 6371 5841 5258 4165 767 16964 16541 16401 16172 16082 15688 15377 15257 15176 14662 14432 14225 14054 13837 13176 13099 12920 12540 12480 11912 11781 11257 11148 11105 10688 10649 10535 9927 9879 9462 9356 9234 9079 8395 8048 7532 7008 6859 6820 
16726 15057 14832 6371 6370 6160 58...

result:

ok Good Job

Test #17:

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

input:

4393 35
10294 10161 2612 1537 3347 8611 9520 5100 2644 12055 12500 4703 9283 1849 4987 1875 9481 10803 4930 3448 6176 7559 1053 8767 13138 5128 8843 10051 7485 2324 9982 5459 1343 3123 540 1718 1532 12179 3580 1610 1234 9632 4164 311 13056 10420 9070 12937 10723 9230 3191 10915 1535 2980 3170 5312 8...

output:

10938 6167 3744 12588 12458 12313 12281 12217 11876 11671 11393 11386 11280 11226 11168 9999 9822 9677 9436 9302 9086 8614 8611 8562 8450 8317 8183 8174 7911 7575 7271 7172 6332 6176 6089 
10938 6167 5887 5447 5266 5128 4983 4824 4502 4322 4062 3861 3744 3740 3562 3173 2414 2233 2157 2035 2011 1966 ...

result:

ok Good Job

Test #18:

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

input:

3114 23
4854 2210 1741 3107 7001 2570 5596 76 988 1255 3256 1503 2438 4831 1103 7315 7570 8195 5048 3387 8688 7064 4148 434 189 7658 7365 3752 3166 9053 8692 2790 1221 1686 1235 6792 290 3887 1578 6972 9133 8443 6188 8931 6148 7781 2829 6963 6834 4107 4385 5559 9262 967 2611 629 272 3599 6860 349 24...

output:

9297 7277 6269 4146 2273 8855 8756 8736 8471 8273 8260 7723 7658 7457 6806 6374 6332 6122 5936 5437 5421 5232 4723 
9297 7277 6269 4649 4435 4373 4277 4232 4147 4146 4113 3566 3270 3007 2916 2823 2273 2090 2036 1892 1765 1535 928 
900 697 613 604 592 527 397 9307 9297 9262 9216 9212 9174 9173 9167 9...

result:

ok Good Job

Test #19:

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

input:

1835 11
1421 3865 961 3020 1348 4937 2618 3465 61 1949 4121 5311 4501 4921 4722 2334 4962 5146 3890 2552 2155 5168 4449 2355 240 1379 4987 224 604 4193 570 1008 878 682 1230 1783 5207 4999 365 2039 4743 422 49 4891 1792 4818 5051 2802 3575 985 3835 1992 4770 5400 1753 4027 2158 64 4465 291 3794 65 1...

output:

386 269 5360 4956 4814 4589 4161 4040 3657 2970 2446 
2211 2065 1922 1871 1734 1662 1463 1367 1299 1294 1243 
1237 1134 1051 943 412 397 386 269 39 5500 5495 
5461 5390 5381 5360 5323 5306 5293 5279 5253 5246 5229 
5198 5189 5168 5145 5126 5087 5068 5065 5063 5062 5043 
5029 5013 5008 4987 4962 4956...

result:

ok Good Job

Test #20:

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

input:

556 40
1663 280 272 1276 1235 865 588 418 1529 957 248 1283 624 452 997 108 1656 1655 1456 942 1423 203 288 1350 112 1137 39 1134 1469 925 462 113 314 113 525 1536 1436 668 1607 1659 1244 417 593 1370 1657 1531 888 455 946 1532 1541 215 1237 1432 596 660 1259 1065 1481 114 202 935 441 1625 1154 246 ...

output:

1659 1657 1655 1374 1128 942 782 668 624 113 97 1664 1633 1625 1603 1591 1552 1549 1548 1536 1502 1494 1472 1469 1447 1436 1367 1361 1331 1316 1297 1284 1283 1240 1152 1111 1011 960 959 957 
1659 1657 1655 1374 1128 956 942 888 858 817 782 694 668 624 614 613 611 601 589 560 557 553 525 511 478 416 ...

result:

ok Good Job

Test #21:

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

input:

9177 28
20232 17428 4155 26994 6484 3856 6297 23998 22610 21836 15103 15765 25620 17823 9274 19421 2291 1364 1074 18319 8645 8368 14762 5238 2487 3077 3869 8768 17937 9554 12373 26208 5971 297 11170 14239 21342 24556 23694 17029 17331 11627 19319 20741 18180 26417 4039 1002 13352 18099 4155 24651 16...

output:

25260 18124 21882 16968 10390 8800 4201 3519 3441 632 27514 27501 27375 27290 27219 27161 27073 26971 26556 26469 26453 26425 25899 25888 25137 24964 24924 24724 
25260 18124 24512 24491 24446 23834 23436 23382 22739 22393 22349 22073 21882 21755 21746 21740 21323 21116 20812 20758 20644 20289 20269...

result:

ok Good Job

Test #22:

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

input:

7898 16
11215 2335 3296 4655 17318 18049 2496 11678 17212 302 22477 8923 11542 572 1812 8204 4127 2536 4863 18158 18371 11529 21331 13541 2694 12853 6111 22686 10009 3310 14747 19818 5820 22610 11773 2699 16348 9096 17957 5749 12166 14103 1141 16250 7766 42 18039 18957 9544 9399 8959 15690 11638 145...

output:

22801 19449 18750 18200 17315 16535 9009 7168 7072 4978 4602 23564 23447 22825 22813 22054 
22801 21736 21728 21331 21170 21135 20495 19853 19651 19553 19449 19403 19206 19163 18907 18750 
18661 18477 18200 18158 17829 17619 17477 17315 17303 17285 17162 16933 16858 16850 16827 16535 
16451 16321 16...

result:

ok Good Job