QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#949246 | #8920. Восстание газонокосилок | xiapali# | 40 | 50ms | 3840kb | C++20 | 1.9kb | 2025-03-23 19:32:08 | 2025-03-23 19:32:08 |
Judging History
answer
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>
using namespace __gnu_pbds;
using namespace std;
template<class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3,unroll-loops")
mt19937 rnd(238);
#define len(a) (int) a.size()
#define pb push_back
#define pbb pop_back
#define all(a) a.begin(), a.end()
#define rev reverse
#define ff first
#define ss second
#define vec vector
#define str string
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define umap unordered_map
#define pri pair<int, int>
#define prl pair<ll, ll>
const int MOD = 1e9 + 7;
const int BLOCK_SZ = 1000;
const ll inf = 1e18;
const int INF = 1e9;
const int mod = 1e9 + 7;
const int sz = 4000;
struct robot {
ll x, p, d;
};
void solve() {
int n;
cin >> n;
vector<robot> a(n);
for (int i = 0; i < n; i++) cin >> a[i].x >> a[i].p >> a[i].d;
ll ans = inf;
for (int i = -1; i < n; i++) {
bool ok = true;
for (int j = 0; j + 1 <= i; j++) {
if (a[j + 1].x - a[j].x > a[j].p) ok = false;
}
for (int j = n - 1; j - 1 > i; j--) {
if (a[j].x - a[j - 1].x > a[j].p) ok = false;
}
if (ok) {
if (a[i].x + a[i].p >= a[i + 1].x - a[i + 1].p) {
ll cnt = 0;
for (int j = 0; j < n; j++) {
if (j <= i && a[j].d == -1) cnt++;
if (j > i && a[j].d == 1) cnt++;
}
ans = min(ans, cnt);
}
}
}
if (ans == inf) cout << -1;
else cout << ans;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int _ = 1;
while (_--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 23
Accepted
Test #1:
score: 23
Accepted
time: 0ms
memory: 3584kb
input:
10 0 9 1 1 6 1 2 4 1 3 2 1 4 3 1 5 4 -1 7 4 1 8 7 -1 9 4 1 10 7 1
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 23
Accepted
time: 0ms
memory: 3712kb
input:
10 0 3 1 1 5 -1 11 5 1 16 3 -1 22 8 -1 23 4 1 28 4 1 34 3 1 39 7 1 40 5 -1
output:
-1
result:
ok 1 number(s): "-1"
Test #3:
score: 23
Accepted
time: 0ms
memory: 3712kb
input:
10 0 12 -1 1 2 1 14 18 -1 19 18 1 31 9 1 33 4 1 34 18 1 36 15 -1 46 15 -1 63 6 1
output:
-1
result:
ok 1 number(s): "-1"
Test #4:
score: 23
Accepted
time: 0ms
memory: 3584kb
input:
10 0 630608459 -1 99534806 668585190 -1 109086445 929464356 1 217136748 478194593 1 352297971 197486632 -1 365911158 539729730 1 461993653 781006864 -1 488768249 875897690 1 506991884 971941607 1 513148437 562630670 -1
output:
4
result:
ok 1 number(s): "4"
Test #5:
score: 23
Accepted
time: 0ms
memory: 3712kb
input:
6 0 9 1 1 7 1 3 7 1 4 3 -1 6 1 -1 7 7 -1
output:
1
result:
ok 1 number(s): "1"
Test #6:
score: 23
Accepted
time: 1ms
memory: 3584kb
input:
10 0 9 1 9 11 1 20 3 -1 23 1 1 24 18 1 42 6 -1 53 5 1 70 17 -1 76 6 -1 100 24 1
output:
4
result:
ok 1 number(s): "4"
Test #7:
score: 23
Accepted
time: 1ms
memory: 3712kb
input:
10 0 3 -1 2 4 -1 13 7 -1 21 9 -1 24 3 -1 27 4 1 33 6 -1 58 26 -1 68 11 -1 100 32 1
output:
4
result:
ok 1 number(s): "4"
Test #8:
score: 23
Accepted
time: 0ms
memory: 3584kb
input:
10 0 14620135 1 14619649 67492279 -1 82111877 92368562 1 174479944 44651960 1 219131755 66340745 1 305947635 20475928 1 484391538 178444404 1 496149253 11757753 -1 630583086 134434525 1 1000000000 369417252 -1
output:
4
result:
ok 1 number(s): "4"
Test #9:
score: 23
Accepted
time: 0ms
memory: 3712kb
input:
10 0 11151 -1 11151 1830 -1 12981 1225 -1 22537 8331 -1 32662 10125 -1 39510 6848 -1 62604 23094 1 68558 5954 1 82045 13487 1 123456 41410 -1
output:
-1
result:
ok 1 number(s): "-1"
Test #10:
score: 23
Accepted
time: 0ms
memory: 3712kb
input:
10 0 89628821 1 89628750 39194053 1 128823848 110237151 1 239060899 122905660 1 361966024 72284352 -1 434249475 22842655 -1 579153572 122062369 1 621403934 42251228 1 680140325 58737342 -1 1000000000 319859750 1
output:
-1
result:
ok 1 number(s): "-1"
Test #11:
score: 23
Accepted
time: 0ms
memory: 3712kb
input:
10 0 1 1 1 1 1 2 1 1 3 1 1 4 1 1 5 1 -1 6 1 1 7 1 -1 8 1 1 9 1 -1
output:
2
result:
ok 1 number(s): "2"
Subtask #2:
score: 0
Time Limit Exceeded
Test #12:
score: 16
Accepted
time: 0ms
memory: 3584kb
input:
10 0 2 1 6 5 1 30 6 1 43 8 1 48 3 1 50 9 1 60 10 1 72 7 1 77 8 1 80 7 1
output:
-1
result:
ok 1 number(s): "-1"
Test #13:
score: 16
Accepted
time: 0ms
memory: 3712kb
input:
100 0 9706359 1 4010340 5139532 1 9155946 4085372 1 10589722 5738127 1 23419068 2070230 1 27738854 6288025 1 33937892 2918930 1 34311768 4657439 1 40823439 5939122 1 45032364 6110475 1 46403154 1003945 1 59136098 5006589 1 67216994 120288 1 71862076 4028359 1 76552553 4451765 1 82049610 9022832 1 82...
output:
-1
result:
ok 1 number(s): "-1"
Test #14:
score: 16
Accepted
time: 50ms
memory: 3820kb
input:
10000 0 76431 1 100748 63751 1 420013 89748 1 562526 29316 1 836219 61301 1 897326 11302 1 1017865 36657 1 1046067 48760 1 1168440 95263 1 1330591 38297 1 1351586 50213 1 1576552 57883 1 1670802 64290 1 1750320 94404 1 1868468 7077 1 1880574 15664 1 1904278 74259 1 1924402 84461 1 1947449 31237 1 19...
output:
-1
result:
ok 1 number(s): "-1"
Test #15:
score: 0
Time Limit Exceeded
input:
100000 0 277 1 405 2794 1 502 1908 1 1648 3819 1 1663 4398 1 3354 8921 1 4701 6214 1 5011 3363 1 5377 9189 1 8672 2125 1 10120 8281 1 10465 4668 1 11216 2049 1 11639 3884 1 12923 7714 1 13635 6203 1 14271 2997 1 14603 4363 1 14780 1734 1 15423 6515 1 16631 3447 1 19170 2303 1 19822 8363 1 19858 4828...
output:
result:
Subtask #3:
score: 17
Accepted
Dependency #1:
100%
Accepted
Test #20:
score: 17
Accepted
time: 1ms
memory: 3712kb
input:
1000 0 551525 -1 342965 314510 -1 881133 954277 -1 948047 920531 1 1076015 141846 1 1257798 477540 1 1264130 742614 1 1442897 581444 1 1470658 687724 1 1601603 730583 1 1844560 526462 1 1948263 155113 -1 2022891 241304 1 2084831 192423 1 2143483 984812 -1 2236413 987683 -1 2306502 710989 -1 2316006 ...
output:
-1
result:
ok 1 number(s): "-1"
Test #21:
score: 17
Accepted
time: 1ms
memory: 3712kb
input:
1000 0 45162413 1 342401 46695466 1 548981 19989399 -1 925520 26865055 1 1172037 93802153 -1 1964568 92106914 1 1993378 81287679 -1 2226931 63863042 -1 2239482 39689275 1 2602069 14180433 -1 3885734 15947778 1 4522849 26517095 -1 4614325 22392700 1 5279282 24414687 -1 5293844 42291416 1 5500802 4563...
output:
-1
result:
ok 1 number(s): "-1"
Test #22:
score: 17
Accepted
time: 1ms
memory: 3712kb
input:
1000 0 396952019 1 155603 571886325 1 516329 218089554 1 1794531 484487361 1 2156521 117197825 1 2305058 588616756 1 2817167 84205197 -1 3456345 628750664 -1 4059916 420899034 -1 4282685 493025898 -1 5947807 779951487 -1 6390081 86541049 -1 8064274 442664261 1 8154025 537189836 1 8680373 390719403 1...
output:
483
result:
ok 1 number(s): "483"
Test #23:
score: 17
Accepted
time: 0ms
memory: 3840kb
input:
1000 0 376 1 376 268 1 644 798 -1 1442 1873 -1 3315 1419 1 4734 1232 1 5966 579 -1 6545 441 1 6986 354 -1 7340 264 -1 7604 3495 -1 11099 416 1 11515 637 -1 12152 3436 1 15588 357 1 15945 1138 1 17083 4341 1 21424 451 -1 21875 301 -1 22176 131 1 22307 735 1 23042 205 -1 23247 228 -1 23475 169 1 23644...
output:
494
result:
ok 1 number(s): "494"
Test #24:
score: 17
Accepted
time: 1ms
memory: 3584kb
input:
1000 0 1650990 -1 1650191 555386 -1 2205511 272659 1 2478020 1070275 1 3547928 197201 1 3744164 712552 -1 4455962 332055 1 4787067 639518 -1 5426364 1870761 -1 7296935 1686895 1 8982907 629075 1 9611733 985386 1 10596951 1222015 -1 11818103 958691 1 12776710 2108167 1 14884351 2002400 -1 16886333 14...
output:
505
result:
ok 1 number(s): "505"
Test #25:
score: 17
Accepted
time: 0ms
memory: 3712kb
input:
1000 0 1090 -1 1090 309 -1 1399 599 1 1998 401 1 2399 1270 1 3669 774 1 4443 555 1 4998 357 -1 5355 3 1 5358 3109 1 8467 105 1 8572 231 -1 8803 56 1 8859 2296 -1 11155 1724 -1 12879 705 -1 13584 195 -1 13779 442 1 14221 2528 -1 16749 329 -1 17078 67 1 17145 1637 -1 18782 774 1 19556 215 -1 19771 122...
output:
-1
result:
ok 1 number(s): "-1"
Test #26:
score: 17
Accepted
time: 0ms
memory: 3712kb
input:
1000 0 364111 -1 363551 835990 -1 1198698 449599 -1 1648186 2362786 -1 4010048 676796 1 4686168 223715 -1 4911041 3516023 -1 8426164 842730 -1 9268708 1719438 1 10987815 2328475 -1 13315429 2207825 -1 15522504 2685802 1 18207862 74151 -1 18281158 88215 -1 18368700 1994193 -1 20361902 600523 1 209621...
output:
-1
result:
ok 1 number(s): "-1"
Test #27:
score: 17
Accepted
time: 1ms
memory: 3712kb
input:
1000 0 1 -1 1 1 -1 2 1 -1 3 1 -1 4 1 -1 5 1 -1 6 1 -1 7 1 -1 8 1 -1 9 1 -1 10 1 -1 11 1 -1 12 1 -1 13 1 -1 14 1 -1 15 1 -1 16 1 -1 17 1 -1 18 1 -1 19 1 -1 20 1 -1 21 1 -1 22 1 -1 23 1 -1 24 1 -1 25 1 -1 26 1 -1 27 1 -1 28 1 -1 29 1 -1 30 1 -1 31 1 -1 32 1 -1 33 1 -1 34 1 -1 35 1 -1 36 1 -1 37 1 -1 3...
output:
6
result:
ok 1 number(s): "6"
Test #28:
score: 17
Accepted
time: 1ms
memory: 3584kb
input:
1000 0 1 1 1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1 20 1 1 21 1 1 22 1 1 23 1 1 24 1 1 25 1 1 26 1 1 27 1 1 28 1 1 29 1 1 30 1 1 31 1 1 32 1 1 33 1 1 34 1 1 35 1 1 36 1 1 37 1 1 38 1 1 39 1 1 40 1 1 41 1 1 42 1 1 43 1...
output:
4
result:
ok 1 number(s): "4"
Test #29:
score: 17
Accepted
time: 0ms
memory: 3712kb
input:
1000 0 1 1 1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1 20 1 1 21 1 1 22 1 1 23 1 1 24 1 1 25 1 1 26 1 1 27 1 1 28 1 1 29 1 1 30 1 1 31 1 1 32 1 1 33 1 1 34 1 1 35 1 1 36 1 1 37 1 1 38 1 1 39 1 1 40 1 1 41 1 1 42 1 1 43 1...
output:
6
result:
ok 1 number(s): "6"
Test #30:
score: 17
Accepted
time: 0ms
memory: 3712kb
input:
1000 0 1 -1 1 1 -1 2 1 -1 3 1 -1 4 1 -1 5 1 -1 6 1 -1 7 1 -1 8 1 -1 9 1 -1 10 1 -1 11 1 -1 12 1 -1 13 1 -1 14 1 -1 15 1 -1 16 1 -1 17 1 -1 18 1 -1 19 1 -1 20 1 -1 21 1 -1 22 1 -1 23 1 -1 24 1 -1 25 1 -1 26 1 -1 27 1 -1 28 1 -1 29 1 -1 30 1 -1 31 1 -1 32 1 -1 33 1 -1 34 1 -1 35 1 -1 36 1 -1 37 1 -1 3...
output:
47
result:
ok 1 number(s): "47"
Test #31:
score: 17
Accepted
time: 1ms
memory: 3840kb
input:
1000 0 1 1 1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1 20 1 -1 21 1 1 22 1 1 23 1 1 24 1 1 25 1 1 26 1 1 27 1 1 28 1 1 29 1 1 30 1 1 31 1 1 32 1 1 33 1 1 34 1 1 35 1 1 36 1 1 37 1 -1 38 1 1 39 1 1 40 1 1 41 1 1 42 1 1 43...
output:
37
result:
ok 1 number(s): "37"
Test #32:
score: 17
Accepted
time: 0ms
memory: 3712kb
input:
1000 0 1 1 1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1 20 1 1 21 1 1 22 1 1 23 1 1 24 1 1 25 1 1 26 1 1 27 1 1 28 1 1 29 1 1 30 1 1 31 1 1 32 1 1 33 1 1 34 1 1 35 1 -1 36 1 1 37 1 1 38 1 1 39 1 1 40 1 1 41 1 1 42 1 1 43 ...
output:
50
result:
ok 1 number(s): "50"
Subtask #4:
score: 0
Runtime Error
Test #33:
score: 13
Accepted
time: 0ms
memory: 3584kb
input:
1000 0 1 1 1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 -1 12 1 1 13 1 1 14 1 1 15 1 1 16 1 -1 17 1 -1 18 1 -1 19 1 1 20 1 1 21 1 1 22 1 1 23 1 -1 24 1 1 25 1 -1 26 1 -1 27 1 1 28 1 -1 29 1 1 30 1 1 31 1 -1 32 1 1 33 1 -1 34 1 -1 35 1 1 36 1 1 37 1 1 38 1 -1 39 1 -1 40 1 -1 41 1...
output:
460
result:
ok 1 number(s): "460"
Test #34:
score: 0
Runtime Error
input:
100000 0 1 -1 1 1 1 2 1 1 3 1 1 4 1 -1 5 1 1 6 1 -1 7 1 -1 8 1 1 9 1 1 10 1 -1 11 1 1 12 1 -1 13 1 1 14 1 1 15 1 1 16 1 -1 17 1 1 18 1 -1 19 1 -1 20 1 1 21 1 1 22 1 1 23 1 1 24 1 -1 25 1 -1 26 1 1 27 1 -1 28 1 1 29 1 1 30 1 1 31 1 1 32 1 1 33 1 -1 34 1 1 35 1 -1 36 1 -1 37 1 -1 38 1 -1 39 1 -1 40 1 ...
output:
result:
Subtask #5:
score: 0
Runtime Error
Test #41:
score: 0
Runtime Error
input:
100000 0 1000000000 1 8647 1000000000 -1 17560 1000000000 -1 41175 1000000000 1 47287 1000000000 1 55634 1000000000 -1 60818 1000000000 1 67825 1000000000 1 69518 1000000000 1 71061 1000000000 1 84754 1000000000 -1 100792 1000000000 -1 118181 1000000000 -1 123883 1000000000 -1 125803 1000000000 -1 1...
output:
result:
Subtask #6:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%