답안 #821323

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
821323 2023-08-11T09:07:54 Z makanhulia Lasers (NOI19_lasers) C++17
100 / 100
282 ms 45004 KB
#include <bits/stdc++.h>
#define ll long long
#define longlonginf LONG_LONG_MAX
using namespace std;

ll n,m,x;
ll l,r;

void solve(){
  cin>>n;
  cin>>m;
  vector<vector<ll>> v(m+5);
  ll rem[m+5];
  memset(rem,0,sizeof(rem));
  for(int i = 0 ; i < m ; i++){
    cin>>x;
    while(x--){
      ll k;
      cin>>k;
      v[i].push_back(k);
      rem[i] += k;
    }
    rem[i] = n-rem[i];
  }
  vector<pair<ll,ll>> p;
  for(int i = 0 ; i < m ; i++){
    ll k = 0;
    for(auto x : v[i]){
      r = k+x;
      l = k+1;
      if( l+rem[i]-1 < r ){
        p.push_back({l+rem[i],r});
        //cout<<"{"<<l+rem[i]<<","<<r<<"} ";
      }
      k += x;
    }
    //cout<<"\n";
  }
  if( p.empty() ){
    cout<<0<<"\n";
    return;
  }
  sort(p.begin(),p.end());
  p.push_back({longlonginf,longlonginf});
  ll cur = p[0].first;
  ll mx = p[0].second;
  ll ans = 0;
  for(auto x : p){
    if( x.first <= mx ){
      mx = max(mx,x.second);
    }
    else{
      //cout<<"! "<<cur<<" "<<mx<<"\n";
      ans += mx-cur+1;
      cur = x.first;
      mx = max(mx,x.second);
    }
  }
  cout<<ans<<"\n";
}

int main(){
  int T = 1;
  //cin>>T;
  for(int i = 1 ; i <= T ; i++){
    solve();
  }
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 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 296 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 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 296 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 262 ms 45004 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 304 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 248 ms 41564 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 296 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 7448 KB Output is correct
2 Correct 10 ms 1708 KB Output is correct
3 Correct 13 ms 1736 KB Output is correct
4 Correct 52 ms 7512 KB Output is correct
5 Correct 25 ms 4796 KB Output is correct
6 Correct 56 ms 5944 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 57 ms 6972 KB Output is correct
9 Correct 27 ms 7080 KB Output is correct
10 Correct 70 ms 7876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 7448 KB Output is correct
2 Correct 10 ms 1708 KB Output is correct
3 Correct 13 ms 1736 KB Output is correct
4 Correct 52 ms 7512 KB Output is correct
5 Correct 25 ms 4796 KB Output is correct
6 Correct 56 ms 5944 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 57 ms 6972 KB Output is correct
9 Correct 27 ms 7080 KB Output is correct
10 Correct 70 ms 7876 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 241 ms 39840 KB Output is correct
22 Correct 33 ms 3476 KB Output is correct
23 Correct 17 ms 2700 KB Output is correct
24 Correct 68 ms 10520 KB Output is correct
25 Correct 250 ms 39856 KB Output is correct
26 Correct 81 ms 8656 KB Output is correct
27 Correct 24 ms 3088 KB Output is correct
28 Correct 245 ms 39768 KB Output is correct
29 Correct 247 ms 39928 KB Output is correct
30 Correct 58 ms 7140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 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 296 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 262 ms 45004 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 304 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 248 ms 41564 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 296 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 49 ms 7448 KB Output is correct
22 Correct 10 ms 1708 KB Output is correct
23 Correct 13 ms 1736 KB Output is correct
24 Correct 52 ms 7512 KB Output is correct
25 Correct 25 ms 4796 KB Output is correct
26 Correct 56 ms 5944 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 57 ms 6972 KB Output is correct
29 Correct 27 ms 7080 KB Output is correct
30 Correct 70 ms 7876 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 241 ms 39840 KB Output is correct
42 Correct 33 ms 3476 KB Output is correct
43 Correct 17 ms 2700 KB Output is correct
44 Correct 68 ms 10520 KB Output is correct
45 Correct 250 ms 39856 KB Output is correct
46 Correct 81 ms 8656 KB Output is correct
47 Correct 24 ms 3088 KB Output is correct
48 Correct 245 ms 39768 KB Output is correct
49 Correct 247 ms 39928 KB Output is correct
50 Correct 58 ms 7140 KB Output is correct
51 Correct 35 ms 3224 KB Output is correct
52 Correct 273 ms 40948 KB Output is correct
53 Correct 260 ms 40928 KB Output is correct
54 Correct 56 ms 6004 KB Output is correct
55 Correct 128 ms 12700 KB Output is correct
56 Correct 68 ms 9680 KB Output is correct
57 Correct 83 ms 9884 KB Output is correct
58 Correct 282 ms 41200 KB Output is correct
59 Correct 59 ms 6316 KB Output is correct
60 Correct 87 ms 8188 KB Output is correct