# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
643011 | 2022-09-21T04:17:14 Z | devariaota | Lasers (NOI19_lasers) | C++17 | 270 ms | 13284 KB |
#include <bits/stdc++.h> #define ll long long #define fi first #define se second #define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); const ll MOD=1e9+7; using namespace std; ll N,M,s[500005]; vector <pair<ll,ll> > vec; int main(){ cin>>N>>M; for(int i=1;i<=M;i++){ cin>>s[i]; ll a[s[i]+1]; ll pref[s[i]+1]; ll suff[s[i]+1]; for(int j=1;j<=s[i];j++){ ll y; cin>>y; a[j]=y; } pref[0]=0; suff[s[i]+1]=0; for(int j=1;j<=s[i];j++){ pref[j]=pref[j-1]+a[j]; } for(int j=s[i];j>=1;j--){ suff[j]=suff[j+1]+a[j]; } for(int j=1;j<=s[i];j++){ ll l=N-suff[j]+1; ll r=pref[j]; if(l<=r){ vec.push_back({l,r}); } } } sort(vec.begin(),vec.end()); if(vec.empty()){ cout<<0<<endl; return 0; } ll l=vec[0].fi; ll r=vec[0].se; ll ans=r-l+1; for(int i=1;i<vec.size();i++){ if(vec[i].fi>r){ l=vec[i].fi; r=vec[i].se; ans+=vec[i].se-vec[i].fi+1; } else if(vec[i].se>r){ l=vec[i].fi; r=vec[i].se; ans+=vec[i].se-r; } } cout<<ans<<endl; } /* 20 6 1 8 2 2 8 3 2 2 8 4 2 2 2 8 5 2 2 2 2 8 6 2 2 2 2 2 8 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 263 ms | 11844 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 316 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 270 ms | 13284 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 55 ms | 8252 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 55 ms | 8252 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 263 ms | 11844 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 316 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 270 ms | 13284 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Incorrect | 55 ms | 8252 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |