QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#119832 | #1156. Robots | somethingnew# | 100 ✓ | 238ms | 16832kb | C++20 | 2.2kb | 2023-07-05 21:33:25 | 2024-07-04 00:19:25 |
Judging History
answer
// ↘ ⬇ ⬇ ⬇ ⬇ ⬇ ↙
// ➡ @roadfromroi ⬅
// ↗ ⬆ ⬆ ⬆ ⬆ ⬆ ↖
#include <iostream>
#include "vector"
#include "algorithm"
#include "numeric"
#include "climits"
#include "iomanip"
#include "bitset"
#include "cmath"
#include "map"
#include "deque"
#include "array"
#include "set"
#define all(x) x.begin(), x.end()
using namespace std;
#include "robots.h"
struct dsu {
vector<int> p;
vector<int> cnt;
void init(int n, int k) {
p.assign(n, {});
cnt.assign(n, k);
for (int i = 0; i < n; ++i) {
p[i] = i;
}
}
int getv(int v) {
if (v == p.size())
return v;
if (p[v] == v)
return v;
return p[v] = getv(p[v]);
}
bool op(int v) {
v = getv(v);
if (v == p.size())
return 0;
cnt[v]--;
if (cnt[v] == 0)
p[v] = v + 1;
return 1;
}
};
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
vector<int> a;
vector<int> b;
for (int i = 0; i < A; ++i) {
a.push_back(X[i]);
}
for (int i = 0; i < B; ++i) {
b.push_back(Y[i]);
}
sort(all(a));
sort(all(b));
vector<pair<int, int>> prpr;
for (int i = 0; i < T; ++i) {
W[i] = upper_bound(all(a), W[i]) - a.begin();
S[i] = upper_bound(all(b), S[i]) - b.begin();
prpr.push_back({W[i], S[i]});
}
sort(all(prpr));
reverse(all(prpr));
int l = 0, r = T + 2;
while (l + 1 < r) {
int m = l + r >> 1;
bool gd = 1;
dsu usdx, usdy;
usdx.init(a.size(), m);
usdy.init(b.size(), m);
for (auto [x, y] : prpr) {
if (usdy.op(y) == 0) {
if (usdx.op(x) == 0) {
gd = 0;
break;
}
}
}
if (gd) {
r = m;
} else {
l = m;
}
}
if (r > T) {
return -1;
}
return r;
}
/*
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int t;
cin >> t;
}
*/
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 14
Accepted
Test #1:
score: 14
Accepted
time: 0ms
memory: 5908kb
input:
1 1 2 13 13 5 6 13 13
output:
-1
result:
ok single line: '-1'
Test #2:
score: 0
Accepted
time: 1ms
memory: 5824kb
input:
0 2 2 20 10 7 10 13 10
output:
2
result:
ok single line: '2'
Test #3:
score: 0
Accepted
time: 1ms
memory: 6060kb
input:
2 0 2 10 20 10 7 10 13
output:
2
result:
ok single line: '2'
Test #4:
score: 0
Accepted
time: 0ms
memory: 5848kb
input:
1 1 2 13 13 15 6 5 16
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 5844kb
input:
0 2 2 15 15 7 8 5 6
output:
1
result:
ok single line: '1'
Test #6:
score: 0
Accepted
time: 1ms
memory: 6076kb
input:
2 0 2 15 15 7 8 5 6
output:
1
result:
ok single line: '1'
Test #7:
score: 0
Accepted
time: 1ms
memory: 5844kb
input:
2 0 2 20 1 10 10 10 10
output:
2
result:
ok single line: '2'
Subtask #2:
score: 14
Accepted
Test #8:
score: 14
Accepted
time: 124ms
memory: 14692kb
input:
50000 0 500000 1957680000 64280000 235160000 1384760000 1279320000 1005400000 1481760000 1129920000 1774640000 494160000 763120000 419640000 1742880000 1083000000 278360000 64040000 576880000 1479760000 1872320000 158480000 1183880000 81320000 249920000 30920000 1909240000 870920000 842280000 445640...
output:
17
result:
ok single line: '17'
Test #9:
score: 0
Accepted
time: 78ms
memory: 16740kb
input:
50000 0 500000 1259308694 1722606921 1479714896 1475931297 1942320254 1106961993 1138541861 1203363162 1463675587 1275336085 1847766630 1321488338 1222281203 1591977596 1409525422 1599394067 1145145532 1323526439 1598712171 1714056360 1476058962 1328447976 1935622082 1438076232 1341274687 1862703150...
output:
-1
result:
ok single line: '-1'
Test #10:
score: 0
Accepted
time: 15ms
memory: 6940kb
input:
50000 0 50000 113928 75954 27813 115923 126882 62226 23610 50853 75387 41997 41316 45291 109398 32691 53328 120774 113403 75204 143499 136305 2766 4464 134799 7683 14460 87384 12351 103104 59130 17037 129444 97344 145227 146124 27390 123153 66891 70968 61710 51729 103593 9702 107829 22188 118152 962...
output:
2
result:
ok single line: '2'
Test #11:
score: 0
Accepted
time: 155ms
memory: 16528kb
input:
50000 0 500000 138858 89022 139041 109101 28452 78147 110283 112965 95913 2007 37164 6264 147498 143694 12576 3606 104232 96870 67764 62778 121602 58416 119397 35865 71124 79884 62370 93516 133611 115716 55941 146244 100728 52704 55095 15102 135777 59718 7869 131775 33159 122232 22851 121371 59238 8...
output:
11
result:
ok single line: '11'
Test #12:
score: 0
Accepted
time: 155ms
memory: 15072kb
input:
50000 0 500000 776960000 773040000 1171760000 1106920000 1732640000 446960000 890920000 1737520000 183680000 728320000 1966120000 942880000 1218000000 694600000 1128640000 1696200000 1193000000 1572880000 532400000 1039840000 1833680000 1441840000 1447480000 553240000 366480000 515920000 1723560000 ...
output:
15
result:
ok single line: '15'
Test #13:
score: 0
Accepted
time: 106ms
memory: 15252kb
input:
50000 0 500000 1387853151 1101982239 1390128723 1447889751 1825875294 1064550393 1343204970 1060204064 1069119716 1342433657 1845505214 1670914465 1462776488 1460089570 1107081731 1950533753 1254549911 1866646965 1625749264 1138872479 1104010740 1231654841 1769368758 1137413788 1611385869 1233773347...
output:
10
result:
ok single line: '10'
Subtask #3:
score: 25
Accepted
Dependency #1:
100%
Accepted
Test #14:
score: 25
Accepted
time: 0ms
memory: 5856kb
input:
3 2 10 6 2 9 4 7 4 6 8 5 2 3 7 9 1 8 5 1 3 3 8 7 7 6 10 5
output:
3
result:
ok single line: '3'
Test #15:
score: 0
Accepted
time: 0ms
memory: 7892kb
input:
2 1 3 2 5 2 3 1 5 3 2 2
output:
-1
result:
ok single line: '-1'
Test #16:
score: 0
Accepted
time: 1ms
memory: 7892kb
input:
25 25 50 18 51 45 57 63 54 30 3 24 21 66 48 6 75 42 72 15 69 39 12 27 9 60 36 33 37 35 13 5 45 43 7 31 11 3 21 1 29 17 15 23 47 41 33 27 9 19 39 49 25 80 662167866 41 854818619 59 750281022 32 713696017 137 1142260087 35 1705242223 65 375567545 107 321944609 68 1918798449 62 1099136337 122 169708110...
output:
-1
result:
ok single line: '-1'
Test #17:
score: 0
Accepted
time: 1ms
memory: 5832kb
input:
49 1 50 63 27 87 54 60 105 147 99 30 45 9 72 48 33 24 51 120 126 36 42 66 141 108 69 78 57 123 3 135 90 93 81 129 111 114 12 75 21 18 132 144 15 102 117 39 138 96 6 84 10 124 15 73 15 67 15 40 15 118 15 112 15 10 15 130 15 28 15 127 15 100 15 16 15 119 5 55 15 121 15 13 15 58 15 139 15 7 15 79 15 64...
output:
2
result:
ok single line: '2'
Test #18:
score: 0
Accepted
time: 1ms
memory: 5832kb
input:
1 49 50 10 81 129 135 78 27 96 42 132 45 144 105 18 93 108 138 102 147 90 87 120 39 3 84 63 6 72 123 54 24 30 117 12 66 114 21 75 126 33 57 36 15 69 9 141 99 51 48 111 60 15 22 15 130 5 80 15 139 15 34 15 127 15 100 15 31 15 1 15 91 15 112 15 73 15 28 15 133 15 106 15 97 15 145 15 61 15 94 15 49 15 ...
output:
2
result:
ok single line: '2'
Test #19:
score: 0
Accepted
time: 0ms
memory: 6128kb
input:
25 25 50 1040000000 560000000 1760000000 1600000000 720000000 240000000 1200000000 1440000000 880000000 320000000 960000000 1120000000 480000000 1920000000 800000000 160000000 400000000 640000000 1680000000 1840000000 1360000000 1520000000 80000000 2000000000 1280000000 1920000000 480000000 10400000...
output:
-1
result:
ok single line: '-1'
Test #20:
score: 0
Accepted
time: 0ms
memory: 5900kb
input:
24 26 50 416666665 1416666661 499999998 1333333328 1083333329 1999999992 1916666659 583333331 999999996 1833333326 166666666 1749999993 249999999 833333330 1666666660 916666663 1583333327 333333332 666666664 749999997 1166666662 83333333 1499999994 1249999995 1307692292 1692307672 1923076900 3076923...
output:
2
result:
ok single line: '2'
Subtask #4:
score: 37
Accepted
Dependency #3:
100%
Accepted
Test #21:
score: 37
Accepted
time: 4ms
memory: 5992kb
input:
500 500 10000 175769951 78234442 1989276125 579229354 1738605419 248650831 1893061510 1407903740 1171874474 1768669963 1239985614 979317232 887530302 529213821 1493976544 567840865 536061097 207463241 290134169 1673628081 1493976544 1823996536 587655611 1673628081 1138738442 675708366 372215090 9304...
output:
11
result:
ok single line: '11'
Test #22:
score: 0
Accepted
time: 3ms
memory: 8068kb
input:
500 500 10000 1999907172 1999907172 1999907172 1999907172 1999907172 1999907172 1999907172 1999907172 1999907172 1999907172 1999907172 1999907172 1999907172 1999907172 1999907172 1999907172 1999907172 1999907172 1999907172 1999907172 1999907172 1999907172 1999907172 1999907172 1999907172 1999907172 ...
output:
10
result:
ok single line: '10'
Test #23:
score: 0
Accepted
time: 1ms
memory: 5824kb
input:
50 50 50 51 7 77 65 57 85 13 83 9 71 87 47 31 89 43 99 61 5 53 95 55 39 45 93 73 81 1 29 15 37 49 3 27 91 35 21 41 67 69 33 25 97 75 79 63 19 17 23 11 59 93 111 108 54 96 114 45 3 129 6 105 69 84 99 81 21 63 123 141 126 27 87 147 36 42 78 117 9 144 72 60 18 138 135 15 30 48 57 75 150 12 51 66 102 13...
output:
2
result:
ok single line: '2'
Test #24:
score: 0
Accepted
time: 4ms
memory: 5948kb
input:
512 488 10000 281250000 562500000 1753906250 1312500000 667968750 1738281250 207031250 195312500 1667968750 550781250 1500000000 1382812500 652343750 300781250 488281250 1613281250 156250000 183593750 1789062500 468750000 1300781250 1792968750 375000000 1882812500 1710937500 1363281250 574218750 132...
output:
10
result:
ok single line: '10'
Subtask #5:
score: 10
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Dependency #4:
100%
Accepted
Test #25:
score: 10
Accepted
time: 237ms
memory: 15452kb
input:
50000 50000 500000 208398181 1845063198 1134825502 1643803709 1532449020 1158775061 362576785 1581659943 284852526 192517779 753233392 1946415461 687321340 1987718881 493150485 93783713 1314250099 1081600197 1559998402 712064123 451419087 170695136 690084865 1494151417 620777633 725519615 473043228 ...
output:
6
result:
ok single line: '6'
Test #26:
score: 0
Accepted
time: 106ms
memory: 16700kb
input:
50000 50000 500000 1999991769 1999991769 1999991769 1999991769 1999991769 1999991769 1999991769 1999991769 1999991769 1999991769 1999991769 1999991769 1999991769 1999991769 1999991769 1999991769 1999991769 1999991769 1999991769 1999991769 1999991769 1999991769 1999991769 1999991769 1999991769 199999...
output:
5
result:
ok single line: '5'
Test #27:
score: 0
Accepted
time: 94ms
memory: 16196kb
input:
0 50000 500000 1737500674 1584193959 1585534110 1048279957 1893748549 1162713242 1154299100 1859285448 1938788920 1232125511 1154297421 1950309571 1561684914 1675035430 1401634230 1294618279 1107806584 1672814984 1631887912 1991457011 1357432372 1639565178 1022528877 1462863859 1723271811 190994340...
output:
10
result:
ok single line: '10'
Test #28:
score: 0
Accepted
time: 148ms
memory: 16264kb
input:
50000 50000 500000 219640000 1146000000 1486400000 74360000 499280000 405440000 589720000 1147920000 652800000 77240000 140240000 874120000 1825120000 825440000 1365440000 455400000 390480000 487840000 880880000 152280000 1719360000 1368560000 1878280000 1766360000 1062760000 937880000 1756400000 16...
output:
348762
result:
ok single line: '348762'
Test #29:
score: 0
Accepted
time: 196ms
memory: 15248kb
input:
50000 50000 500000 1977960000 374280000 1300480000 1863280000 678320000 1356720000 1794560000 1784640000 653040000 1718040000 1856920000 1992120000 580840000 1156280000 1799080000 1248320000 1622960000 1233000000 213200000 1590680000 1314720000 1105760000 187640000 473400000 779920000 1638600000 137...
output:
66850
result:
ok single line: '66850'
Test #30:
score: 0
Accepted
time: 106ms
memory: 15772kb
input:
50000 50000 500000 1083680000 291400000 1334880000 421320000 1027200000 980920000 753080000 1023200000 120920000 52680000 832200000 405360000 824680000 888360000 647440000 195360000 161920000 1441480000 233640000 1134320000 1146840000 587600000 1737360000 919840000 1853200000 411280000 1595960000 17...
output:
500000
result:
ok single line: '500000'
Test #31:
score: 0
Accepted
time: 238ms
memory: 16832kb
input:
50000 50000 500000 1782040000 803240000 1774320000 301320000 1596680000 1687440000 225680000 1568240000 38560000 1550320000 1770280000 247440000 1685040000 917120000 1445000000 228640000 931640000 1610240000 1662920000 1572040000 1016240000 1275880000 389840000 1112240000 132240000 361560000 1673360...
output:
5
result:
ok single line: '5'