답안 #815957

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
815957 2023-08-09T02:56:07 Z andecaandeci Lasers (NOI19_lasers) C++17
100 / 100
274 ms 16764 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

int presum[500005];
vector<pair<int, int>> segment;

signed main() {
  int l, r, x, w;
  cin >> l >> r;
  for (int i = 1; i <= r; i++) {
    cin >> x;
    for (int j = 1; j <= x; j++) {
      cin >> w;
      presum[j] = presum[j-1] + w;
    }
    int gap = l - presum[x];
    for (int j = 1; j <= x; j++) {
      if (presum[j-1] + gap + 1 <= presum[j]) {
        segment.push_back({presum[j-1] + gap + 1, 1});
        segment.push_back({presum[j], 2});
      }
    }
  }

  // Line Sweep

  sort(segment.begin(), segment.end());
  int count = 0, save, ans = 0;

  for (auto i: segment) {
    if (i.second == 1) {
      if (count == 0) save = i.first;
      count++;
    } else {
      count--;
      if (count == 0) ans += (i.first-save+1);
    }
  }

  cout << ans << endl;
}

Compilation message

lasers.cpp: In function 'int main()':
lasers.cpp:38:38: warning: 'save' may be used uninitialized in this function [-Wmaybe-uninitialized]
   38 |       if (count == 0) ans += (i.first-save+1);
      |                               ~~~~~~~^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 232 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 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 1 ms 212 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 1 ms 232 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 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 1 ms 212 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 212 KB Output is correct
12 Correct 262 ms 16764 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 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 250 ms 8616 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
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 9784 KB Output is correct
2 Correct 12 ms 1868 KB Output is correct
3 Correct 16 ms 1276 KB Output is correct
4 Correct 78 ms 9908 KB Output is correct
5 Correct 36 ms 5588 KB Output is correct
6 Correct 54 ms 5144 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 75 ms 4308 KB Output is correct
9 Correct 37 ms 9344 KB Output is correct
10 Correct 80 ms 10064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 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 1 ms 212 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 9784 KB Output is correct
2 Correct 12 ms 1868 KB Output is correct
3 Correct 16 ms 1276 KB Output is correct
4 Correct 78 ms 9908 KB Output is correct
5 Correct 36 ms 5588 KB Output is correct
6 Correct 54 ms 5144 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 75 ms 4308 KB Output is correct
9 Correct 37 ms 9344 KB Output is correct
10 Correct 80 ms 10064 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 216 ms 8540 KB Output is correct
22 Correct 33 ms 2500 KB Output is correct
23 Correct 20 ms 2672 KB Output is correct
24 Correct 101 ms 9396 KB Output is correct
25 Correct 218 ms 8620 KB Output is correct
26 Correct 85 ms 8536 KB Output is correct
27 Correct 29 ms 2440 KB Output is correct
28 Correct 218 ms 8620 KB Output is correct
29 Correct 244 ms 8588 KB Output is correct
30 Correct 72 ms 4836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 232 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 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 1 ms 212 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 212 KB Output is correct
12 Correct 262 ms 16764 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 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 250 ms 8616 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 Correct 68 ms 9784 KB Output is correct
22 Correct 12 ms 1868 KB Output is correct
23 Correct 16 ms 1276 KB Output is correct
24 Correct 78 ms 9908 KB Output is correct
25 Correct 36 ms 5588 KB Output is correct
26 Correct 54 ms 5144 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 75 ms 4308 KB Output is correct
29 Correct 37 ms 9344 KB Output is correct
30 Correct 80 ms 10064 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 216 ms 8540 KB Output is correct
42 Correct 33 ms 2500 KB Output is correct
43 Correct 20 ms 2672 KB Output is correct
44 Correct 101 ms 9396 KB Output is correct
45 Correct 218 ms 8620 KB Output is correct
46 Correct 85 ms 8536 KB Output is correct
47 Correct 29 ms 2440 KB Output is correct
48 Correct 218 ms 8620 KB Output is correct
49 Correct 244 ms 8588 KB Output is correct
50 Correct 72 ms 4836 KB Output is correct
51 Correct 32 ms 2664 KB Output is correct
52 Correct 274 ms 8616 KB Output is correct
53 Correct 249 ms 8548 KB Output is correct
54 Correct 77 ms 4512 KB Output is correct
55 Correct 163 ms 8700 KB Output is correct
56 Correct 79 ms 9216 KB Output is correct
57 Correct 117 ms 8604 KB Output is correct
58 Correct 237 ms 8528 KB Output is correct
59 Correct 68 ms 4492 KB Output is correct
60 Correct 92 ms 4540 KB Output is correct