QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#507215 | #4742. Prawnicy | Nevll | 35 | 191ms | 19324kb | C++14 | 1.1kb | 2024-08-06 13:46:46 | 2024-08-06 13:46:46 |
Judging History
answer
# include <bits/stdc++.h>
# define ll long long
# define ld long double
# define pii pair<int, int>
# define fi first
# define se second
using namespace std;
int main() {
int N, K;
scanf("%d %d", &N, &K);
vector<pair<pii, int> > arr(N);
for(int i=0;i<N;i++) {
scanf("%d %d", &arr[i].fi.fi, &arr[i].fi.se);
arr[i].se = i;
}
sort(arr.begin(), arr.end());
priority_queue<int> PQ;
int sp = -1, len = -1;
for(int c=0;c<arr.size();c++) {
if(PQ.size() >= K - 1) {
int st = c, l = min(-PQ.top(), arr[c].fi.se) - arr[c].fi.fi;
l = max(l, 0);
if(l >= len) {
len = l;
sp = st;
}
}
PQ.push(-arr[c].fi.se);
if(PQ.size() > K - 1) PQ.pop();
}
printf("%d\n", len);
vector<int> ans;
ans.clear();
priority_queue<pii> P;
for(int c=0;c<sp;c++) {
P.push({-arr[c].fi.se, arr[c].se});
if(P.size() > K - 1) P.pop();
}
ans.push_back(arr[sp].se);
while(P.size()) {
ans.push_back(P.top().se);
P.pop();
}
sort(ans.begin(), ans.end());
for(auto p : ans) printf("%d ", p + 1);
printf("\n");
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 20
Accepted
Test #1:
score: 20
Accepted
time: 0ms
memory: 4032kb
input:
6 3 3 8 4 12 2 6 1 10 5 9 11 12
output:
4 2 4 5
result:
ok good answer on both questions!
Test #2:
score: 20
Accepted
time: 0ms
memory: 3724kb
input:
13 7 30 65 3 20 24 55 9 30 6 25 39 80 33 70 36 75 15 40 12 35 18 45 21 50 27 60
output:
11 1 3 6 7 8 12 13
result:
ok good answer on both questions!
Test #3:
score: 20
Accepted
time: 0ms
memory: 3796kb
input:
7 2 2 5 2 5 4 7 4 7 5 8 5 8 3 5
output:
3 5 6
result:
ok good answer on both questions!
Test #4:
score: 20
Accepted
time: 0ms
memory: 4060kb
input:
9 3 16 32 21 36 68 80 66 80 27 46 15 32 32 43 64 80 23 41
output:
12 3 4 8
result:
ok good answer on both questions!
Test #5:
score: 20
Accepted
time: 0ms
memory: 4056kb
input:
17 7 2 27 1 50 171 220 190 228 208 220 1 38 188 227 192 221 212 239 54 83 30 74 1 44 3 28 1 39 191 221 3 29 287 320
output:
24 1 2 6 12 13 14 16
result:
ok good answer on both questions!
Test #6:
score: 20
Accepted
time: 0ms
memory: 4024kb
input:
20 4 420 488 209 280 335 424 328 413 279 363 246 314 289 349 269 350 296 391 365 441 347 444 198 270 179 276 286 362 368 439 315 361 359 415 274 348 380 425 399 490
output:
62 5 8 14 18
result:
ok good answer on both questions!
Test #7:
score: 20
Accepted
time: 0ms
memory: 3728kb
input:
19 5 290 295 77 125 168 201 230 235 282 330 138 153 73 76 356 374 263 273 201 222 180 195 291 332 108 111 90 107 280 327 290 337 289 333 334 359 41 46
output:
36 5 12 15 16 17
result:
ok good answer on both questions!
Test #8:
score: 20
Accepted
time: 0ms
memory: 3800kb
input:
20 10 248 260 72 87 356 372 69 88 82 103 404 414 68 87 50 71 68 89 77 97 131 142 77 96 74 87 25 37 402 416 81 87 130 144 201 211 78 91 70 89
output:
6 2 4 7 9 10 12 13 16 19 20
result:
ok good answer on both questions!
Test #9:
score: 20
Accepted
time: 0ms
memory: 3792kb
input:
20 4 385 426 12 37 386 419 240 275 2 43 234 274 232 278 169 205 225 269 379 395 381 402 232 280 164 209 5 39 218 263 157 205 219 265 385 398 233 275 171 207
output:
40 6 7 12 19
result:
ok good answer on both questions!
Test #10:
score: 20
Accepted
time: 0ms
memory: 4024kb
input:
20 5 1 4 1 3 2 4 1 4 1 3 1 3 1 3 2 3 2 3 2 3 1 3 1 3 1 3 2 4 2 4 2 3 2 4 2 4 1 3 2 4
output:
2 1 3 4 14 20
result:
ok good answer on both questions!
Test #11:
score: 20
Accepted
time: 0ms
memory: 4068kb
input:
20 5 1 2 1 4 1 2 3 4 1 4 2 4 2 4 1 3 1 2 3 4 2 3 2 4 2 4 3 4 2 3 1 4 1 3 3 4 1 2 2 4
output:
2 2 5 6 7 20
result:
ok good answer on both questions!
Test #12:
score: 20
Accepted
time: 0ms
memory: 4020kb
input:
7 3 34 43 2 11 26 40 25 31 28 40 4 11 5 9
output:
6 1 3 5
result:
ok good answer on both questions!
Test #13:
score: 20
Accepted
time: 0ms
memory: 3792kb
input:
17 12 15004623 108198380 6001923 43279283 16004923 115411613 13004023 93771914 12003723 86558681 5001623 36066050 2000723 14426351 14004323 100985147 9002823 64918982 8002523 57705749 7002223 50492516 17005223 122624846 3001023 21639584 1000423 7213118 4001323 28852817 10003123 72132215 11003423 793...
output:
26274060 1 2 3 4 5 8 9 10 11 12 16 17
result:
ok good answer on both questions!
Test #14:
score: 20
Accepted
time: 0ms
memory: 4056kb
input:
13 3 144503784 144503877 396967175 396967284 144503792 144503895 97541682 97541769 97541695 97541773 396967215 396967290 144503794 144503897 396967206 396967299 341685161 341685238 183786823 183786855 144503824 144503871 97541651 97541754 144503822 144503909
output:
83 1 3 7
result:
ok good answer on both questions!
Test #15:
score: 20
Accepted
time: 0ms
memory: 3796kb
input:
11 5 148518837 148519034 218763545 218763716 218763460 218763629 148518746 148518953 148518748 148518937 157058642 157058644 148518806 148518951 148518805 148518967 218763374 218763583 218763537 218763661 218763510 218763684
output:
100 1 4 5 7 8
result:
ok good answer on both questions!
Test #16:
score: 20
Accepted
time: 0ms
memory: 3788kb
input:
16 2 358241830 363111811 727033309 731013915 411688284 416477252 411666324 416485126 147619720 152282502 411545550 416440647 726262823 730896523 726510268 730157192 414570702 417226273 448013367 450785589 445112827 450108967 358906711 362152369 359080349 363970270 728291140 732766025 148622237 15258...
output:
4788968 3 4
result:
ok good answer on both questions!
Test #17:
score: 20
Accepted
time: 0ms
memory: 3796kb
input:
20 5 114686836 630742792 680381266 918567885 306589686 877764658 45777970 953967857 206159325 380008169 82422754 388987434 508562180 934623235 449225963 740196668 54887384 802558239 30279672 991075652 37271901 945918881 705212488 999411310 748738003 892622799 81640248 491079951 554413663 893332591 4...
output:
601141796 4 10 11 18 19
result:
ok good answer on both questions!
Test #18:
score: 20
Accepted
time: 0ms
memory: 4072kb
input:
17 5 330190158 332327308 993204118 997033392 253661688 256762727 990448750 994614033 591337231 595937865 991144392 995946497 362313651 363170096 819112158 821085949 774729685 775633155 367063850 371805650 672197048 677166123 477905527 478001653 124430569 126788050 458656856 462332175 379822338 38328...
output:
579094 2 4 6 16 17
result:
ok good answer on both questions!
Test #19:
score: 20
Accepted
time: 0ms
memory: 4024kb
input:
20 10 3021122 62914915 9590555 82439856 11486930 86614270 28193580 96472669 124877 64584820 6972012 69667799 10712521 85858677 2866497 77182935 22760881 95458927 24162165 92439450 5248844 97449091 6310210 91726917 8424445 51635398 22359403 35198737 5348823 71734495 16724837 97883357 5876881 86565561...
output:
58277691 2 3 7 9 10 11 12 16 17 20
result:
ok good answer on both questions!
Test #20:
score: 20
Accepted
time: 0ms
memory: 3852kb
input:
20 7 7727671 180735109 7827116 267861675 11019977 309692538 53849518 242335995 32248046 327525848 30777756 81715214 60015335 254276432 207027568 208648532 49746698 254928154 20174222 246105304 823377 304696090 65030900 84815715 55625651 223334544 87892472 281710386 542630245 556510000 5179186 164984...
output:
194261097 2 3 5 7 9 11 18
result:
ok good answer on both questions!
Test #21:
score: 20
Accepted
time: 0ms
memory: 3864kb
input:
20 5 3 999999998 3 999999999 3 1000000000 2 1000000000 2 999999999 1 999999999 3 999999998 1 999999999 3 999999998 3 999999999 1 999999999 1 999999998 3 1000000000 1 999999998 2 999999998 3 999999999 1 1000000000 1 999999998 1 999999998 1 999999999
output:
999999998 6 8 11 17 20
result:
ok good answer on both questions!
Test #22:
score: 20
Accepted
time: 0ms
memory: 3768kb
input:
20 5 3 4 1 5 3 7 4 6 4 5 1 6 2 7 2 5 2 6 5 7 2 7 1 3 1 7 2 3 5 6 5 7 2 5 5 6 2 3 2 4
output:
4 6 7 9 11 13
result:
ok good answer on both questions!
Subtask #2:
score: 15
Accepted
Test #23:
score: 15
Accepted
time: 0ms
memory: 3768kb
input:
217 21 13 175 13 276 13 297 13 138 13 184 13 265 13 203 13 176 13 110 13 282 13 267 13 218 13 84 13 135 13 195 13 225 13 129 13 124 13 148 13 219 13 162 13 142 13 180 13 94 13 153 13 149 13 254 13 125 13 168 13 83 13 299 13 200 13 103 13 247 13 164 13 143 13 259 13 288 13 214 13 88 13 272 13 102 13 ...
output:
266 3 10 31 38 64 65 76 87 101 107 116 134 140 147 157 160 164 182 185 188 203
result:
ok good answer on both questions!
Test #24:
score: 15
Accepted
time: 0ms
memory: 3772kb
input:
233 33 255 291 19 104 199 294 207 284 108 216 38 148 260 289 23 107 48 156 4 92 12 88 108 184 201 297 15 114 112 209 69 171 224 299 12 66 191 299 83 190 211 298 20 99 261 298 189 284 204 295 3 111 206 295 154 204 78 132 3 71 10 61 212 300 18 41 19 119 193 299 119 210 239 296 53 113 43 122 23 113 207...
output:
74 2 8 14 22 26 34 40 50 65 66 68 76 81 86 98 102 106 110 113 127 130 141 156 159 172 185 186 189 198 221 222 224 231
result:
ok good answer on both questions!
Test #25:
score: 15
Accepted
time: 0ms
memory: 3776kb
input:
150 17 5 65 116 215 12 109 8 106 1 77 87 180 9 67 6 77 88 162 2 94 27 100 1 82 115 178 14 108 86 183 81 152 45 143 19 108 5 41 8 42 82 179 11 83 1 77 6 70 12 100 20 115 7 105 3 85 8 107 3 72 4 84 17 75 78 156 92 153 70 108 124 211 4 100 76 167 41 117 6 80 37 114 1 38 2 78 81 180 7 77 66 158 5 71 57 ...
output:
82 6 15 21 44 49 50 68 74 78 86 89 109 113 124 138 141 146
result:
ok good answer on both questions!
Test #26:
score: 15
Accepted
time: 0ms
memory: 3804kb
input:
300 100 190 293 142 281 183 286 107 140 88 284 176 181 68 192 109 295 204 234 177 299 18 88 19 265 89 291 91 269 2 25 119 168 47 246 96 271 62 258 76 101 57 188 17 207 43 275 165 241 19 294 127 236 206 285 31 288 5 131 172 277 132 283 16 228 172 298 93 260 51 289 99 300 42 182 44 238 146 254 112 265...
output:
159 12 17 19 23 25 28 35 42 46 48 49 54 55 56 58 60 65 67 70 71 75 77 78 82 84 94 97 98 100 101 103 108 115 116 118 120 121 125 126 128 131 132 136 138 140 141 143 148 157 158 162 164 166 168 170 171 174 176 177 179 190 196 202 206 210 211 212 215 217 218 221 227 228 231 234 235 237 240 244 245 246 ...
result:
ok good answer on both questions!
Test #27:
score: 15
Accepted
time: 0ms
memory: 3800kb
input:
300 55 104 204 78 249 42 271 29 277 52 259 16 264 35 274 27 249 82 246 79 239 3 269 69 256 22 209 22 239 41 254 67 282 24 281 27 216 47 256 40 271 220 278 48 227 15 249 65 287 49 234 16 197 53 242 95 272 107 284 1 300 59 253 74 232 8 296 46 221 79 300 5 203 31 192 22 151 61 267 10 279 30 246 34 295 ...
output:
223 4 6 7 11 17 30 33 40 42 45 49 59 61 64 69 84 85 87 93 101 106 107 109 114 125 133 134 136 143 145 147 148 153 156 164 165 178 180 183 208 219 221 228 243 245 247 249 250 257 271 291 292 294 297 300
result:
ok good answer on both questions!
Test #28:
score: 15
Accepted
time: 0ms
memory: 3772kb
input:
275 79 55 264 34 55 14 178 72 226 90 291 85 186 1 296 105 272 46 274 13 20 4 295 101 214 64 265 5 230 4 300 72 195 36 281 88 233 29 115 241 249 43 165 41 210 47 296 15 23 23 129 89 188 145 278 119 196 7 234 34 150 40 189 52 108 40 295 25 207 46 218 91 198 55 134 130 157 28 199 72 275 159 213 18 164 ...
output:
174 1 7 9 11 13 15 17 23 33 40 43 49 51 52 57 58 63 64 65 71 72 73 75 79 82 89 92 95 96 106 108 111 113 121 122 123 124 128 133 135 142 145 148 151 162 163 164 168 170 174 176 185 186 189 190 191 195 196 204 207 211 212 213 220 225 226 227 231 234 245 247 249 250 261 263 264 268 270 271
result:
ok good answer on both questions!
Test #29:
score: 15
Accepted
time: 0ms
memory: 3796kb
input:
300 17 104 215 19 299 45 268 14 161 35 90 32 227 35 274 69 299 51 247 141 199 13 218 138 271 7 290 79 290 61 270 22 266 25 237 239 252 48 106 20 280 8 276 230 233 159 261 115 243 76 291 43 184 18 259 100 282 75 233 48 103 203 240 2 124 38 248 54 86 12 232 24 290 53 205 1 299 71 109 25 240 50 183 106...
output:
278 13 38 45 85 92 108 125 139 152 177 191 198 220 255 274 275 285
result:
ok good answer on both questions!
Test #30:
score: 15
Accepted
time: 0ms
memory: 3804kb
input:
300 37 141 246 8 61 127 257 94 209 190 288 51 125 149 260 64 181 141 269 114 238 175 239 183 267 174 277 134 256 148 262 62 183 110 235 148 270 140 252 154 262 189 299 151 282 192 274 54 186 111 235 124 243 6 133 168 275 174 251 154 263 199 275 96 220 125 255 164 287 138 268 137 263 127 254 131 263 ...
output:
120 3 14 33 37 38 51 56 58 76 86 92 96 101 105 111 116 135 139 147 160 171 172 174 175 180 200 204 217 221 236 248 253 258 259 269 271 275
result:
ok good answer on both questions!
Test #31:
score: 15
Accepted
time: 0ms
memory: 3856kb
input:
300 30 1 300 3 296 1 297 5 297 5 300 4 300 5 299 1 296 1 299 4 299 5 299 3 300 1 299 3 298 3 298 5 298 2 296 4 300 5 297 5 298 3 299 5 296 5 298 4 298 2 300 2 300 5 297 1 299 1 298 4 297 5 297 2 300 5 300 1 296 4 299 5 300 4 299 4 296 4 296 5 298 4 298 5 298 2 300 2 298 5 299 5 298 2 300 4 297 4 299...
output:
297 1 12 25 26 32 43 47 61 67 69 74 89 90 96 102 103 138 140 142 148 154 158 179 187 188 201 208 212 220 255
result:
ok good answer on both questions!
Test #32:
score: 15
Accepted
time: 0ms
memory: 3724kb
input:
300 30 7 9 4 7 5 8 4 5 2 3 2 8 7 8 1 9 1 5 5 8 3 5 7 8 2 7 6 9 1 9 6 8 1 5 2 7 1 8 6 7 3 5 4 5 4 7 2 4 7 8 1 9 3 5 2 3 5 6 1 8 4 9 3 9 5 8 3 7 5 9 6 9 3 4 4 9 1 4 2 8 3 4 6 9 3 7 1 6 4 8 3 6 5 9 2 6 6 7 6 8 4 9 2 4 1 8 4 9 6 8 2 6 3 4 2 7 2 9 2 8 2 4 2 9 1 3 1 9 3 9 3 8 7 9 2 6 6 8 2 9 1 8 4 7 2 4 2...
output:
6 8 15 26 32 59 62 64 65 70 114 115 126 184 185 198 201 214 216 217 226 231 243 245 256 264 265 269 277 288 298
result:
ok good answer on both questions!
Subtask #3:
score: 0
Runtime Error
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Test #33:
score: 15
Accepted
time: 1ms
memory: 3804kb
input:
1000 1000 1 1000001 2 1000002 3 1000003 4 1000004 5 1000005 6 1000006 7 1000007 8 1000008 9 1000009 10 1000010 11 1000011 12 1000012 13 1000013 14 1000014 15 1000015 16 1000016 17 1000017 18 1000018 19 1000019 20 1000020 21 1000021 22 1000022 23 1000023 24 1000024 25 1000025 26 1000026 27 1000027 28...
output:
999001 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...
result:
ok good answer on both questions!
Test #34:
score: 0
Runtime Error
input:
1000 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...
output:
result:
Subtask #4:
score: 0
Runtime Error
Test #44:
score: 15
Accepted
time: 191ms
memory: 19324kb
input:
513231 513231 1845228 79920475 526638 33895405 10039260 365931211 798021 43367964 5129649 194562408 6360795 237535266 10147872 369722287 1617903 71985750 7231833 267938640 6865992 255169047 4929918 187590845 10395504 378365823 10324692 375894147 3728655 145661046 6194811 231741634 9493638 346886405 ...
output:
4736113 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 ...
result:
ok good answer on both questions!
Test #45:
score: 15
Accepted
time: 6ms
memory: 3844kb
input:
13791 13791 167418903 373657222 52048032 191327513 6331741 330762899 116563087 321305848 102476475 273083273 9299823 387224202 51089359 436094893 29884621 355433930 105143380 359042649 127051892 446961791 36401540 373573195 115887809 403138793 165035288 318027181 54876521 185328890 126341414 2640071...
output:
2181121 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 ...
result:
ok good answer on both questions!
Test #46:
score: 0
Runtime Error
input:
150000 1 242105518 997697478 658741563 805161992 538251435 961003551 54777195 812177543 13094229 251024550 57002628 627660759 12321720 181965234 387867813 572185571 157118438 910874185 689123860 953953173 108295848 766161397 562860074 726420280 16734194 412960155 23251215 583346897 201865001 9902560...
output:
result:
Subtask #5:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
0%