QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#815088#8920. Восстание газонокосилокjiangly (Lingyu Jiang)16 14ms4492kbC++231.0kb2024-12-15 03:27:372024-12-15 03:27:38

Judging History

This is the latest submission verdict.

  • [2024-12-15 03:27:38]
  • Judged
  • Verdict: 16
  • Time: 14ms
  • Memory: 4492kb
  • [2024-12-15 03:27:37]
  • Submitted

answer

#include <bits/stdc++.h>

using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int n;
    std::cin >> n;
    
    std::vector<int> x(n), p(n), d(n);
    for (int i = 0; i < n; i++) {
        std::cin >> x[i] >> p[i] >> d[i];
    }
    
    int ans = n + 1;
    
    int cost = std::count(d.begin(), d.end(), 1);
    int bad = 0;
    for (int i = 1; i < n; i++) {
        bad += (p[i] < x[i] - x[i - 1]);
    }
    for (int i = 0; i < n - 1; i++) {
        if (d[i] == 1) {
            cost--;
        } else {
            cost++;
        }
        bad -= (p[i + 1] < x[i + 1] - x[i]);
        if (bad == 0 && p[i] + p[i + 1] >= x[i + 1] - x[i]) {
            ans = std::min(ans, cost);
        }
        bad += (p[i] < x[i + 1] - x[i]);
    }
    
    if (ans > n) {
        ans = -1;
    }
    std::cout << ans << "\n";
    
    return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3480kb

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: 16
Accepted

Test #12:

score: 16
Accepted
time: 0ms
memory: 3608kb

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: 3588kb

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: 2ms
memory: 3672kb

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: 16
Accepted
time: 13ms
memory: 4424kb

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:

-1

result:

ok 1 number(s): "-1"

Test #16:

score: 16
Accepted
time: 11ms
memory: 4492kb

input:

100000
0 11 1
11 7 1
18 17 1
35 18 1
53 2 1
55 4 1
59 15 1
74 3 1
77 2 1
79 17 1
96 4 1
100 8 1
108 16 1
124 3 1
127 33 1
160 2 1
162 1 1
163 2 1
165 10 1
175 9 1
184 10 1
194 8 1
202 7 1
209 6 1
215 6 1
221 16 1
237 8 1
245 1 1
246 10 1
256 14 1
270 2 1
272 5 1
277 18 1
295 10 1
305 12 1
317 1 1
31...

output:

13280

result:

ok 1 number(s): "13280"

Test #17:

score: 16
Accepted
time: 13ms
memory: 4492kb

input:

100000
0 11315 1
11143 9723 1
20710 21305 1
41885 2794 1
43739 14923 1
57896 8739 1
66585 10844 1
76528 5892 1
81444 2450 1
83310 10048 1
92933 16884 1
109743 7692 1
116494 9714 1
125967 2330 1
127951 26149 1
153811 3366 1
157009 2512 1
158935 1906 1
159945 10708 1
169924 31940 1
201534 32069 1
2335...

output:

92375

result:

ok 1 number(s): "92375"

Test #18:

score: 16
Accepted
time: 12ms
memory: 4480kb

input:

100000
0 6 1
6 4 1
10 4 1
14 5 1
19 11 1
30 1 1
31 5 1
36 11 1
47 15 1
62 11 1
73 16 1
89 17 1
106 4 1
110 6 1
116 2 1
118 8 1
126 6 1
132 19 1
151 12 1
163 6 1
169 9 1
178 8 1
186 5 1
191 4 1
195 14 1
209 14 1
223 46 1
269 13 1
282 5 1
287 14 1
301 15 1
316 10 1
326 6 1
332 13 1
345 30 1
375 9 1
38...

output:

-1

result:

ok 1 number(s): "-1"

Test #19:

score: 16
Accepted
time: 14ms
memory: 4356kb

input:

100000
0 1899 1
1395 7477 1
8667 26043 1
33931 13481 1
47321 3659 1
50108 641 1
50149 1702 1
51465 15589 1
66263 16523 1
81847 5703 1
87498 21106 1
108353 7372 1
115647 5059 1
120690 20525 1
141163 14055 1
154566 19377 1
173068 1717 1
174229 32275 1
206446 17734 1
223453 19194 1
242480 2286 1
244287...

output:

-1

result:

ok 1 number(s): "-1"

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Wrong Answer

Test #33:

score: 13
Accepted
time: 0ms
memory: 3604kb

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: 13
Accepted
time: 12ms
memory: 4340kb

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:

49840

result:

ok 1 number(s): "49840"

Test #35:

score: 0
Wrong Answer
time: 11ms
memory: 4336kb

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...

output:

505

result:

wrong answer 1st numbers differ - expected: '504', found: '505'

Subtask #5:

score: 0
Wrong Answer

Test #41:

score: 14
Accepted
time: 8ms
memory: 4364kb

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:

49751

result:

ok 1 number(s): "49751"

Test #42:

score: 0
Wrong Answer
time: 12ms
memory: 4352kb

input:

100000
0 1000000000 -1
14302 1000000000 -1
16639 1000000000 -1
18100 1000000000 -1
19451 1000000000 -1
29667 1000000000 -1
39873 1000000000 -1
44265 1000000000 -1
52392 1000000000 -1
66052 1000000000 -1
95044 1000000000 -1
109076 1000000000 -1
109384 1000000000 -1
110812 1000000000 -1
111953 1000000...

output:

511

result:

wrong answer 1st numbers differ - expected: '510', found: '511'

Subtask #6:

score: 0
Skipped

Dependency #1:

0%