# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1007862 |
2024-06-25T15:22:48 Z |
kebine |
Lasers (NOI19_lasers) |
C++17 |
|
146 ms |
40716 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define pii pair<ll,ll>
#define fi first
#define sec second
#define endl '\n'
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define ordered_multiset tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>
const ll MOD = 998244353;
const ll N = 5e5 + 5;
const ll INF = 1e18;
vector<ll>vec[N];
int32_t main(){
cin.tie(0)->sync_with_stdio(0);
int tc = 1;
// cin >> tc;
while(tc--){
ll n,q; cin >> n >> q;
for(int i=1;i<=q;i++){
ll a; cin >> a;
for(int j=1;j<=a;j++){
ll x; cin >> x;
vec[i].pb(x);
}
}
set<pii>interval;
for(int i=1;i<=q;i++){
ll l = 1;
for(auto j : vec[i]){
ll val = max(0LL, 2*j - (n-l+1));
if(val > 0) interval.insert({l-val+j, l+j-1});
l += j;
}
}
if(interval.size() == 0){
cout << 0 << endl;
continue;
}
ll last = -1, prev = -1, mx = 0, ans = 0;
for(auto i : interval){
if(prev == -1) prev = i.fi;
if(i.fi != prev){
ans += max(0LL, last - max(prev - 1,mx));
mx = max(mx, last);
prev = i.fi;
last = 0;
}
last = i.sec;
}
ans += max(0LL, last - max(prev - 1,mx));
cout << ans << endl;
}
}
/*
1 2 3 4 5 6 7 8 9 10 11 12
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
12124 KB |
Output is correct |
2 |
Correct |
2 ms |
12124 KB |
Output is correct |
3 |
Correct |
2 ms |
12124 KB |
Output is correct |
4 |
Correct |
2 ms |
12124 KB |
Output is correct |
5 |
Correct |
2 ms |
12124 KB |
Output is correct |
6 |
Correct |
2 ms |
12124 KB |
Output is correct |
7 |
Correct |
2 ms |
12124 KB |
Output is correct |
8 |
Correct |
2 ms |
12124 KB |
Output is correct |
9 |
Correct |
2 ms |
12124 KB |
Output is correct |
10 |
Correct |
2 ms |
12124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
12124 KB |
Output is correct |
2 |
Correct |
2 ms |
12124 KB |
Output is correct |
3 |
Correct |
2 ms |
12124 KB |
Output is correct |
4 |
Correct |
2 ms |
12124 KB |
Output is correct |
5 |
Correct |
2 ms |
12124 KB |
Output is correct |
6 |
Correct |
2 ms |
12124 KB |
Output is correct |
7 |
Correct |
2 ms |
12124 KB |
Output is correct |
8 |
Correct |
2 ms |
12124 KB |
Output is correct |
9 |
Correct |
2 ms |
12124 KB |
Output is correct |
10 |
Correct |
2 ms |
12124 KB |
Output is correct |
11 |
Correct |
2 ms |
12124 KB |
Output is correct |
12 |
Correct |
81 ms |
27380 KB |
Output is correct |
13 |
Correct |
2 ms |
12120 KB |
Output is correct |
14 |
Correct |
2 ms |
12124 KB |
Output is correct |
15 |
Correct |
2 ms |
12124 KB |
Output is correct |
16 |
Correct |
2 ms |
12124 KB |
Output is correct |
17 |
Correct |
146 ms |
40716 KB |
Output is correct |
18 |
Correct |
3 ms |
12124 KB |
Output is correct |
19 |
Correct |
3 ms |
12124 KB |
Output is correct |
20 |
Correct |
2 ms |
12124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
16336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
12124 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
16336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
12124 KB |
Output is correct |
2 |
Correct |
2 ms |
12124 KB |
Output is correct |
3 |
Correct |
2 ms |
12124 KB |
Output is correct |
4 |
Correct |
2 ms |
12124 KB |
Output is correct |
5 |
Correct |
2 ms |
12124 KB |
Output is correct |
6 |
Correct |
2 ms |
12124 KB |
Output is correct |
7 |
Correct |
2 ms |
12124 KB |
Output is correct |
8 |
Correct |
2 ms |
12124 KB |
Output is correct |
9 |
Correct |
2 ms |
12124 KB |
Output is correct |
10 |
Correct |
2 ms |
12124 KB |
Output is correct |
11 |
Correct |
2 ms |
12124 KB |
Output is correct |
12 |
Correct |
81 ms |
27380 KB |
Output is correct |
13 |
Correct |
2 ms |
12120 KB |
Output is correct |
14 |
Correct |
2 ms |
12124 KB |
Output is correct |
15 |
Correct |
2 ms |
12124 KB |
Output is correct |
16 |
Correct |
2 ms |
12124 KB |
Output is correct |
17 |
Correct |
146 ms |
40716 KB |
Output is correct |
18 |
Correct |
3 ms |
12124 KB |
Output is correct |
19 |
Correct |
3 ms |
12124 KB |
Output is correct |
20 |
Correct |
2 ms |
12124 KB |
Output is correct |
21 |
Incorrect |
16 ms |
16336 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |