# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1090732 |
2024-09-18T16:11:39 Z |
Evirir |
Lasers (NOI19_lasers) |
C++17 |
|
402 ms |
95132 KB |
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
using ll = long long;
using ld = long double;
using ii = pair<int, int>;
int main()
{
cin.tie(0)->sync_with_stdio(0);
int w,h; cin>>w>>h;
vector<vector<int>> a(h);
forn(i,0,h)
{
int n; cin>>n;
a[i].reserve(n);
forn(j,0,n)
{
int x; cin>>x;
a[i].pb(x);
}
}
vector<vector<ii>> rs(h);
forn(rid,0,h)
{
auto& v = a[rid];
auto& cr = rs[rid];
ll sum = accumulate(all(v), 0);
int l = 0, r = w - sum - 1;
cr.pb({l, r});
for (const auto x : v)
{
l += x;
r += x;
if (l <= cr.back().S + 1)
{
auto [l0, r0] = cr.back();
cr.pop_back();
cr.pb({l0, r});
}
else
{
cr.pb({l, r});
}
}
}
vector<ii> eve;
set<int> ps;
for (const auto& cr : rs)
{
for (const auto& [l, r] : cr)
{
eve.pb({l, 1});
eve.pb({r + 1, -1});
ps.insert(l);
ps.insert(r + 1);
}
}
sort(all(eve), greater<>());
int last = -1;
int cnt = 0;
int ans = 0;
for (const auto p : ps)
{
while (!eve.empty() && eve.back().F == p)
{
int t = eve.back().S;
eve.pop_back();
cnt += t;
}
if (cnt != h && last != -1)
{
ans += p - last;
last = -1;
}
if (cnt == h)
last = p;
}
cout << w - ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
464 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
464 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
600 KB |
Output is correct |
12 |
Correct |
178 ms |
76480 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
604 KB |
Output is correct |
16 |
Correct |
1 ms |
464 KB |
Output is correct |
17 |
Correct |
339 ms |
91612 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
90 ms |
20816 KB |
Output is correct |
2 |
Correct |
15 ms |
3928 KB |
Output is correct |
3 |
Correct |
9 ms |
2776 KB |
Output is correct |
4 |
Correct |
81 ms |
22988 KB |
Output is correct |
5 |
Correct |
28 ms |
9924 KB |
Output is correct |
6 |
Correct |
33 ms |
8424 KB |
Output is correct |
7 |
Correct |
1 ms |
600 KB |
Output is correct |
8 |
Correct |
50 ms |
9936 KB |
Output is correct |
9 |
Correct |
70 ms |
18120 KB |
Output is correct |
10 |
Correct |
105 ms |
25668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
600 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
90 ms |
20816 KB |
Output is correct |
2 |
Correct |
15 ms |
3928 KB |
Output is correct |
3 |
Correct |
9 ms |
2776 KB |
Output is correct |
4 |
Correct |
81 ms |
22988 KB |
Output is correct |
5 |
Correct |
28 ms |
9924 KB |
Output is correct |
6 |
Correct |
33 ms |
8424 KB |
Output is correct |
7 |
Correct |
1 ms |
600 KB |
Output is correct |
8 |
Correct |
50 ms |
9936 KB |
Output is correct |
9 |
Correct |
70 ms |
18120 KB |
Output is correct |
10 |
Correct |
105 ms |
25668 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
604 KB |
Output is correct |
17 |
Correct |
1 ms |
600 KB |
Output is correct |
18 |
Correct |
1 ms |
604 KB |
Output is correct |
19 |
Correct |
1 ms |
604 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
352 ms |
88832 KB |
Output is correct |
22 |
Correct |
49 ms |
8944 KB |
Output is correct |
23 |
Correct |
22 ms |
6608 KB |
Output is correct |
24 |
Correct |
88 ms |
21812 KB |
Output is correct |
25 |
Correct |
356 ms |
88748 KB |
Output is correct |
26 |
Correct |
104 ms |
18760 KB |
Output is correct |
27 |
Correct |
35 ms |
7364 KB |
Output is correct |
28 |
Correct |
315 ms |
88792 KB |
Output is correct |
29 |
Correct |
349 ms |
89116 KB |
Output is correct |
30 |
Correct |
63 ms |
15524 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
464 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
600 KB |
Output is correct |
12 |
Correct |
178 ms |
76480 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
604 KB |
Output is correct |
16 |
Correct |
1 ms |
464 KB |
Output is correct |
17 |
Correct |
339 ms |
91612 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
90 ms |
20816 KB |
Output is correct |
22 |
Correct |
15 ms |
3928 KB |
Output is correct |
23 |
Correct |
9 ms |
2776 KB |
Output is correct |
24 |
Correct |
81 ms |
22988 KB |
Output is correct |
25 |
Correct |
28 ms |
9924 KB |
Output is correct |
26 |
Correct |
33 ms |
8424 KB |
Output is correct |
27 |
Correct |
1 ms |
600 KB |
Output is correct |
28 |
Correct |
50 ms |
9936 KB |
Output is correct |
29 |
Correct |
70 ms |
18120 KB |
Output is correct |
30 |
Correct |
105 ms |
25668 KB |
Output is correct |
31 |
Correct |
1 ms |
344 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
0 ms |
348 KB |
Output is correct |
36 |
Correct |
0 ms |
604 KB |
Output is correct |
37 |
Correct |
1 ms |
600 KB |
Output is correct |
38 |
Correct |
1 ms |
604 KB |
Output is correct |
39 |
Correct |
1 ms |
604 KB |
Output is correct |
40 |
Correct |
0 ms |
348 KB |
Output is correct |
41 |
Correct |
352 ms |
88832 KB |
Output is correct |
42 |
Correct |
49 ms |
8944 KB |
Output is correct |
43 |
Correct |
22 ms |
6608 KB |
Output is correct |
44 |
Correct |
88 ms |
21812 KB |
Output is correct |
45 |
Correct |
356 ms |
88748 KB |
Output is correct |
46 |
Correct |
104 ms |
18760 KB |
Output is correct |
47 |
Correct |
35 ms |
7364 KB |
Output is correct |
48 |
Correct |
315 ms |
88792 KB |
Output is correct |
49 |
Correct |
349 ms |
89116 KB |
Output is correct |
50 |
Correct |
63 ms |
15524 KB |
Output is correct |
51 |
Correct |
32 ms |
9300 KB |
Output is correct |
52 |
Correct |
359 ms |
93688 KB |
Output is correct |
53 |
Correct |
371 ms |
93884 KB |
Output is correct |
54 |
Correct |
60 ms |
12128 KB |
Output is correct |
55 |
Correct |
191 ms |
28912 KB |
Output is correct |
56 |
Correct |
94 ms |
21948 KB |
Output is correct |
57 |
Correct |
115 ms |
21644 KB |
Output is correct |
58 |
Correct |
402 ms |
95132 KB |
Output is correct |
59 |
Correct |
82 ms |
15944 KB |
Output is correct |
60 |
Correct |
106 ms |
19388 KB |
Output is correct |