QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#949236 | #8920. Восстание газонокосилок | xiapali# | 0 | 58ms | 3712kb | C++20 | 1.9kb | 2025-03-23 19:25:54 | 2025-03-23 19:25:55 |
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 = 0; i < n - 1; 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();
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
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:
3
result:
wrong answer 1st numbers differ - expected: '2', found: '3'
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: 58ms
memory: 3684kb
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: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Wrong Answer
Test #33:
score: 0
Wrong Answer
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 38 1 -1 39 1 -1 40 1 -1 41 1...
output:
474
result:
wrong answer 1st numbers differ - expected: '460', found: '474'
Subtask #5:
score: 0
Time Limit Exceeded
Test #41:
score: 0
Time Limit Exceeded
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:
0%