QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#639733 | #1753. Crooked Dealing | oxford01# | AC ✓ | 3ms | 4260kb | C++20 | 1.8kb | 2024-10-13 21:59:17 | 2024-10-13 21:59:17 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (auto i = a; i < (b); ++i)
#define repr(i, a, b) for (auto i = (a) - 1; i >= (b); --i)
#define pb push_back
#define eb emplace_back
#define all(x) begin(x), end(x)
#define sz(x) int((x).size())
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vii = vector<pii>;
template<class T>
inline bool cmax(T &a, const T& b) {
return a < b ? a = b, 1 : 0;
}
template<class T>
inline bool cmin(T &a, const T &b) {
return b < a ? a = b, 1 : 0;
}
const int inf = 0x3f3f3f3f;
const ll linf = 1e18;
const double dinf = numeric_limits<double>::infinity();
int main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
int n, h;
cin >> n >> h;
unordered_map<int, int> cnt;
for (int i = 0; i < n; i++) {
int v;
cin >> v;
cnt[v]++;
}
int lo = 1, hi = n/h, res = 0, mid;
while (lo <= hi) {
mid = (lo+hi)/2;
bool check = true;
vi tmp;
for (auto [key, value] : cnt) {
for (int i = 0; i < min(value, mid); i++) {
tmp.pb(key);
}
}
check &= tmp.size() >= mid*h;
if (check) {
res = mid;
lo = mid + 1;
} else
hi = mid - 1;
}
if (res == 0) cout << "impossible" << endl;
else {
vi tmp;
for (auto [key, value] : cnt) {
for (int i = 0; i < min(value, res); i++) {
tmp.pb(key);
}
}
for (int i = 0; i < res; i++) {
for (int j = i; j < res*h; j += res) {
cout << tmp[j] << " ";
}
cout << endl;
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3532kb
input:
5 1 100 100 100 99 99
output:
99 99 100 100 100
result:
ok Good Job
Test #2:
score: 0
Accepted
time: 1ms
memory: 3788kb
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:
6961 2292 2050 10420 803 5458 11102 7208 1097 3056 3493 1489 5240 1152 5183 7174 5890 6567 6015 2494 11271 8143 8580 3573 10274 10596 808 2460 10977 9396 4560 4990 6184 2701 555 4051 9931 3098 2237 9178 10764 4309 9647 2260 7419 4685 10729 9138 4980 6378 9853 9551 590 1674 9647 2260 4868 4685 56...
result:
ok Good Job
Test #3:
score: 0
Accepted
time: 1ms
memory: 3740kb
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:
2669 6051 1900 6349 2061 6684 5694 6699 6987 6393 7091 2651 6647 371 2409 6200 4234 7277 503 6060 6846 4446 3911 1452 5501 2421 625 522 6173 5201 2401 4978 2515 3779 5354 3772 2301 2039 582 2813 7285 3164 1765 5870 5620 3546 5694 1947 6172 515 3266 6463 7273 371 6319 1885 629 1732 2204 1346 6846 44...
result:
ok Good Job
Test #4:
score: 0
Accepted
time: 1ms
memory: 3676kb
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:
51 193 2345 3067 499 606 2902 1777 1467 2333 3111 2544 452 1367 2061 827 2001 3315 1402 796 3314 537 1751 2198 1178 2871 1779 566 2459 512 1609 2211 2138 1174 3081 1494 791 1108 205 2002 2544 452 419 2061 3045 2001 2206 293 3528 2408 2160 1751 3307 1178 1074 2098 2189 909 3484 2228 688 2048 1174 1...
result:
ok Good Job
Test #5:
score: 0
Accepted
time: 3ms
memory: 4008kb
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:
13965 3677 16401 13130 26630 20240 20450 14990 3126 22845 3056 16265 8210 6719 14155 10963 10132 9512 25484 654 22880 26630 20339 5189 14990 23672 22944 3574 905 12319 1632 14088 21236 7169 24620 7539 1364 24323 22653 10066 5189 25362 8705 12671 23922 11178 2046 27563 24361 690 7169 15132 20208 1...
result:
ok Good Job
Test #6:
score: 0
Accepted
time: 2ms
memory: 4016kb
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:
17257 10181 10983 7484 14309 14818 1479 1412 10411 9212 2654 8026 15433 9710 8773 735 15562 20627 25405 22602 22538 9835 4251 23744 11530 17933 17375 13637 12836 22213 14064 23332 16888 16542 16943 22883 2308 1431 446 3591 20830 5452 7564 2892 13945 22997 4635 14658 11578 19639 1208 22025 10040 114...
result:
ok Good Job
Test #7:
score: 0
Accepted
time: 2ms
memory: 3796kb
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:
5760 2107 1384 15833 7550 14856 9906 6764 20357 20894 15972 10477 1398 1856 8916 8988 4350 15476 386 18280 11477 20532 381 16633 2263 17667 13145 2267 6810 10383 19267 1767 10706 15671 1586 1384 12919 3520 6367 20080 6764 20357 9323 3278 19905 21471 9309 19090 10416 14623 7463 10560 20264 16564 134...
result:
ok Good Job
Test #8:
score: 0
Accepted
time: 2ms
memory: 3844kb
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:
17753 10537 3454 14272 4725 9472 9564 15307 8328 10908 11590 17695 11547 14503 12958 13932 11888 9685 16593 16864 4155 13967 15624 10117 10441 4725 8363 7207 46 1147 10908 916 12608 4457 14704 7871 10421 1615 10511 5556 6591 4155 15479 17235 11427 10441 9812 8496 2120 15342 1147 5548 15729 6412 14...
result:
ok Good Job
Test #9:
score: 0
Accepted
time: 0ms
memory: 3776kb
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:
2096 2851 7621 10897 12871 13193 4236 5423 4445 7854 6576 11850 2946 5833 8530 3019 1506 336 9532 2767 10459 1108 2946 13911 3443 3019 11680 7858 2813 11104 11574 13922 3401 8824 672 4801 6593 7141 7900 11104 4229 13922 6892 13538 672 6289 6593 8433 12987 11305 2703 11001 6892 6754 11345 9019 1...
result:
ok Good Job
Test #10:
score: 0
Accepted
time: 1ms
memory: 3648kb
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:
298 159 3196 2477 936 9413 4002 2381 7047 9579 1703 8001 7354 7229 2297 5139 3644 9361 2261 5195 5336 4775 3252 556 9310 4656 3758 39 2401 5760 107 7879 1784 672 7911 7505 9927 7167 6699 3760 4628 5685 936 3852 8197 9452 1960 4693 2864 5644 3363 6120 3406 5139 11 2290 4396 108 5336 9350 8339 4077 9...
result:
ok Good Job
Test #11:
score: 0
Accepted
time: 1ms
memory: 3732kb
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:
511 5692 3698 6033 3952 1633 2111 601 5791 275 3119 5577 612 5433 3257 241 3727 2717 1248 6215 5467 1384 5671 3796 104 83 6452 4370 1341 779 1164 2689 5747 2819 5791 5064 3119 1722 612 4265 5753 2364 1370 2717 4173 6215 1883 1384 5671 6153 939 1129 1848 124 1341 5493 1768 5046 5747 5485 5909 2707 ...
result:
ok Good Job
Test #12:
score: 0
Accepted
time: 1ms
memory: 3824kb
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:
59 2524 177 1109 768 1385 2561 2662 741 1735 41 1919 2453 2237 720 87 1001 1109 347 1284 1452 2229 1823 112 1150 1919 2453 1780 350 2305 735 1433 287 1798 1452 2229 2026 112 1718 2546 1344 2246 2222 502 774 351 287 2339 370 11 2026 2289 609 1019 262 2145 2281 156 492 351 1396 51 2534 1760 1485 1...
result:
ok Good Job
Test #13:
score: 0
Accepted
time: 3ms
memory: 4260kb
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:
16782 22606 9773 27353 13089 289 16107 5442 26122 6234 28353 12052 431 6204 12890 27036 6488 9296 22961 15343 19351 16844 10901 19427 930 21933 24123 25982 1973 12798 5680 15679 22099 8268 2687 10876 22082 12093 22985 8023 9791 11296 18629 8959 7729 26252 23586 289 4310 5947 26381 6234 14854 21853 ...
result:
ok Good Job
Test #14:
score: 0
Accepted
time: 2ms
memory: 3948kb
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:
3696 9154 23708 687 15774 3582 6469 9244 642 11436 3663 15521 9052 14970 22684 17944 12444 15474 20542 14647 24420 22679 6489 10524 23418 24488 9388 3167 16487 3796 15155 11190 5795 857 19739 9878 17176 9244 642 6722 20228 15521 3965 20057 23285 17944 10087 5201 5281 14647 16728 2133 16762 251 1841...
result:
ok Good Job
Test #15:
score: 0
Accepted
time: 2ms
memory: 4032kb
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:
14930 2485 1899 16874 1931 4197 8698 13206 3282 10096 1359 16519 19439 1164 13096 17711 16236 15009 10305 19354 4512 10923 7985 12105 9828 18971 3032 18543 20270 14510 6246 13979 16425 13096 6128 8066 7907 20578 19408 16263 10923 17110 6919 16600 8325 8119 925 20270 4237 15313 13979 20544 18220 16...
result:
ok Good Job
Test #16:
score: 0
Accepted
time: 2ms
memory: 3800kb
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:
3947 1968 2689 10622 11820 7943 6589 338 13136 2015 7859 6827 14401 9728 11291 14871 407 16054 16701 6614 7025 4898 9715 6790 6492 8621 12859 9356 7050 2645 7736 14493 14554 14735 11118 1048 11379 9185 1244 10996 5037 7631 1158 15003 7628 10691 4433 5776 13859 3651 5535 6733 1665 11676 6227 16208 1...
result:
ok Good Job
Test #17:
score: 0
Accepted
time: 1ms
memory: 4032kb
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:
5035 9006 13155 2294 12403 3388 11870 12134 6998 7676 5367 4124 3600 2823 8100 5610 7928 12163 5207 3744 12737 674 11875 2003 10766 8394 11238 9469 1371 6167 2663 12384 12497 6990 3848 8642 4696 5973 2364 3712 4909 7988 1960 5940 7676 5367 1818 8687 2471 1808 204 7928 8900 5207 1387 10380 674 12469...
result:
ok Good Job
Test #18:
score: 0
Accepted
time: 1ms
memory: 3776kb
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:
8246 1824 1658 8740 6000 4265 2363 4977 6458 3419 1565 9119 6093 9314 3566 5310 618 2774 1065 1895 4961 2757 6806 1660 4837 4676 6522 177 1535 2363 3356 6458 4868 3643 5550 1006 3630 8310 2953 2602 7861 6367 2007 5334 400 6806 4404 7359 7723 4165 177 1535 4720 8443 2453 4868 3643 463 1006 1273 165...
result:
ok Good Job
Test #19:
score: 0
Accepted
time: 1ms
memory: 3852kb
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:
3112 1604 1299 1103 1451 2803 5179 254 2531 5359 1937 905 3409 1299 1294 64 446 2822 3500 4888 3002 175 1402 3661 1851 1294 4778 446 985 281 452 4317 4782 5421 3735 851 1294 3596 1636 3178 1390 452 5426 4782 2750 936 1885 2403 3596 3854 3178 1390 2917 4472 4416 83 4536 1885 2403 269 3854 4426 4...
result:
ok Good Job
Test #20:
score: 0
Accepted
time: 0ms
memory: 3580kb
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:
1182 1559 745 1309 1048 51 1579 1095 910 1413 463 1533 858 1378 423 460 254 782 290 1614 587 956 171 664 113 416 1445 1283 703 1637 429 39 399 817 521 1245 1404 1374 365 792 388 679 204 472 692 1485 1023 13 243 1296 1004 359 858 903 707 1285 1322 1290 1602 1668 1128 415 685 1532 113 957 1406 1283 1...
result:
ok Good Job
Test #21:
score: 0
Accepted
time: 3ms
memory: 4184kb
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:
17649 3961 16426 5758 20262 459 9848 21112 10603 702 24984 16702 385 7647 8800 17417 2421 3771 19708 15283 19813 4868 11378 3922 20009 26189 27248 13225 10760 4406 9457 20109 929 16994 20121 10839 13999 5789 19897 11615 20931 1810 8800 7144 7403 24317 9347 5010 19813 20435 11378 14195 17938 26189 3...
result:
ok Good Job
Test #22:
score: 0
Accepted
time: 3ms
memory: 3952kb
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:
18311 9509 4721 288 11672 22067 9714 2694 18200 20579 9188 13013 19163 22900 21539 6363 19075 4969 17472 18392 12435 23352 14801 17955 8026 21444 8734 2740 8989 2354 17103 16636 11874 22667 13083 18392 5754 22769 12071 22656 8026 21444 18908 18100 3832 22702 14666 15352 19295 2121 13435 13305 339...
result:
ok Good Job