Submission #224619

# Submission time Handle Problem Language Result Execution time Memory
224619 2020-04-18T13:59:58 Z Nightlight Lasers (NOI19_lasers) C++14
100 / 100
192 ms 10024 KB
#include <bits/stdc++.h>
#define pii pair<int, int>
#define l first
#define r second
using namespace std;

int L, N, M;
int pos[500005];
pii ran[500005];
int ans;

int main() {
//  freopen("inp", "r", stdin);
  scanf("%d %d", &L, &N);
  int l, r, p = 0;
  for(int i = 1; i <= N; i++) {
    scanf("%d", &M);
    for(int j = 1; j <= M; j++) {
      scanf("%d", &pos[j]);
      pos[j] += pos[j - 1];
    }
    for(int j = 1; j <= M; j++) {
      l = L - (pos[M] - pos[j - 1]) + 1, r = pos[j];
      if(l <= r) {
        ran[++p] = {l, r};
      }
    }
  }
  sort(ran + 1, ran + p + 1);
  int ln = 0, rn = -1;
  for(int i = 1; i <= p; i++) {
    if(ran[i].l > rn) {
      ans += rn - ln + 1;
      ln = ran[i].l;
      rn = ran[i].r;
    }else {
      rn = max(ran[i].r, rn);
    }
  }
  ans += rn - ln + 1;
  printf("%d\n", ans);
}

Compilation message

lasers.cpp: In function 'int main()':
lasers.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &L, &N);
   ~~~~~^~~~~~~~~~~~~~~~~
lasers.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &M);
     ~~~~~^~~~~~~~~~
lasers.cpp:19:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d", &pos[j]);
       ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 167 ms 10024 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 182 ms 7672 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 2988 KB Output is correct
2 Correct 14 ms 1024 KB Output is correct
3 Correct 17 ms 896 KB Output is correct
4 Correct 56 ms 3064 KB Output is correct
5 Correct 27 ms 1664 KB Output is correct
6 Correct 51 ms 2808 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 57 ms 2808 KB Output is correct
9 Correct 29 ms 2176 KB Output is correct
10 Correct 58 ms 3452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 2988 KB Output is correct
2 Correct 14 ms 1024 KB Output is correct
3 Correct 17 ms 896 KB Output is correct
4 Correct 56 ms 3064 KB Output is correct
5 Correct 27 ms 1664 KB Output is correct
6 Correct 51 ms 2808 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 57 ms 2808 KB Output is correct
9 Correct 29 ms 2176 KB Output is correct
10 Correct 58 ms 3452 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 6 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 168 ms 6520 KB Output is correct
22 Correct 28 ms 1408 KB Output is correct
23 Correct 19 ms 1024 KB Output is correct
24 Correct 69 ms 3212 KB Output is correct
25 Correct 192 ms 6520 KB Output is correct
26 Correct 54 ms 2552 KB Output is correct
27 Correct 24 ms 1280 KB Output is correct
28 Correct 175 ms 6520 KB Output is correct
29 Correct 171 ms 6520 KB Output is correct
30 Correct 52 ms 2424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 167 ms 10024 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 182 ms 7672 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 56 ms 2988 KB Output is correct
22 Correct 14 ms 1024 KB Output is correct
23 Correct 17 ms 896 KB Output is correct
24 Correct 56 ms 3064 KB Output is correct
25 Correct 27 ms 1664 KB Output is correct
26 Correct 51 ms 2808 KB Output is correct
27 Correct 6 ms 384 KB Output is correct
28 Correct 57 ms 2808 KB Output is correct
29 Correct 29 ms 2176 KB Output is correct
30 Correct 58 ms 3452 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 4 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 5 ms 384 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 5 ms 384 KB Output is correct
37 Correct 5 ms 384 KB Output is correct
38 Correct 6 ms 384 KB Output is correct
39 Correct 5 ms 384 KB Output is correct
40 Correct 5 ms 384 KB Output is correct
41 Correct 168 ms 6520 KB Output is correct
42 Correct 28 ms 1408 KB Output is correct
43 Correct 19 ms 1024 KB Output is correct
44 Correct 69 ms 3212 KB Output is correct
45 Correct 192 ms 6520 KB Output is correct
46 Correct 54 ms 2552 KB Output is correct
47 Correct 24 ms 1280 KB Output is correct
48 Correct 175 ms 6520 KB Output is correct
49 Correct 171 ms 6520 KB Output is correct
50 Correct 52 ms 2424 KB Output is correct
51 Correct 27 ms 1664 KB Output is correct
52 Correct 185 ms 7928 KB Output is correct
53 Correct 186 ms 7672 KB Output is correct
54 Correct 48 ms 2604 KB Output is correct
55 Correct 99 ms 5112 KB Output is correct
56 Correct 60 ms 3448 KB Output is correct
57 Correct 68 ms 3508 KB Output is correct
58 Correct 183 ms 7928 KB Output is correct
59 Correct 51 ms 2552 KB Output is correct
60 Correct 68 ms 3576 KB Output is correct