답안 #642243

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
642243 2022-09-19T02:57:59 Z kebine Lasers (NOI19_lasers) C++17
100 / 100
275 ms 4916 KB
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef long long ll;
// const ll mod = 1e9 + 7;
const ll MAXN = 1e6 + 5;
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define sc second
#define endl '\n'
#define gl                        ios_base::sync_with_stdio(0);   cin.tie(0);                     cout.tie(0)

int main()
{
  int l, r;
  cin >> l >> r;

  vector<pii> v;
  for (int i = 0; i < r; i++)
  {
    int x;
    cin >> x;
    int a[x + 1], sum = 0;
    a[0] = 0;
    for (int j = 1; j <= x; j++)
    {
      cin >> a[j];
      sum += a[j];
      a[j] += a[j - 1];
    }

    for (int j = 0; j < x; j++)
    {
      if (l - a[j + 1] > sum - a[j])
        continue;
      int L = l - sum + a[j] + 1, R = a[j + 1];
      if (L <= R)
        v.pb({L, R});
    }
  }

  if (v.empty())
    cout << 0 << endl;
  else
  {
    sort(v.begin(), v.end());

    int ans = 0;
    int L = v[0].fi, R = v[0].sc;
    for (int i = 1; i < v.size(); i++)
    {
      if (v[i].fi > R)
      {
        ans += R - L + 1;
        L = v[i].fi;
        R = v[i].sc;
      }
      else
        R = max(R, v[i].sc);
    }

    ans += R - L + 1;

    cout << ans << endl;
  }
}

Compilation message

lasers.cpp: In function 'int main()':
lasers.cpp:57:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for (int i = 1; i < v.size(); i++)
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 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 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 1 ms 300 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 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 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 1 ms 300 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 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 268 ms 4916 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 275 ms 2632 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 3132 KB Output is correct
2 Correct 13 ms 1096 KB Output is correct
3 Correct 16 ms 980 KB Output is correct
4 Correct 59 ms 3680 KB Output is correct
5 Correct 26 ms 2228 KB Output is correct
6 Correct 57 ms 2772 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 64 ms 2440 KB Output is correct
9 Correct 31 ms 3136 KB Output is correct
10 Correct 61 ms 3760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1 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 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 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 55 ms 3132 KB Output is correct
2 Correct 13 ms 1096 KB Output is correct
3 Correct 16 ms 980 KB Output is correct
4 Correct 59 ms 3680 KB Output is correct
5 Correct 26 ms 2228 KB Output is correct
6 Correct 57 ms 2772 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 64 ms 2440 KB Output is correct
9 Correct 31 ms 3136 KB Output is correct
10 Correct 61 ms 3760 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 1 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 300 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 236 ms 3052 KB Output is correct
22 Correct 33 ms 1476 KB Output is correct
23 Correct 20 ms 1232 KB Output is correct
24 Correct 77 ms 3316 KB Output is correct
25 Correct 230 ms 3080 KB Output is correct
26 Correct 69 ms 3004 KB Output is correct
27 Correct 28 ms 1428 KB Output is correct
28 Correct 226 ms 3116 KB Output is correct
29 Correct 242 ms 3136 KB Output is correct
30 Correct 62 ms 2240 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 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 1 ms 300 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 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 268 ms 4916 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 275 ms 2632 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 55 ms 3132 KB Output is correct
22 Correct 13 ms 1096 KB Output is correct
23 Correct 16 ms 980 KB Output is correct
24 Correct 59 ms 3680 KB Output is correct
25 Correct 26 ms 2228 KB Output is correct
26 Correct 57 ms 2772 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 64 ms 2440 KB Output is correct
29 Correct 31 ms 3136 KB Output is correct
30 Correct 61 ms 3760 KB Output is correct
31 Correct 1 ms 296 KB Output is correct
32 Correct 1 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 300 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 236 ms 3052 KB Output is correct
42 Correct 33 ms 1476 KB Output is correct
43 Correct 20 ms 1232 KB Output is correct
44 Correct 77 ms 3316 KB Output is correct
45 Correct 230 ms 3080 KB Output is correct
46 Correct 69 ms 3004 KB Output is correct
47 Correct 28 ms 1428 KB Output is correct
48 Correct 226 ms 3116 KB Output is correct
49 Correct 242 ms 3136 KB Output is correct
50 Correct 62 ms 2240 KB Output is correct
51 Correct 32 ms 1608 KB Output is correct
52 Correct 269 ms 2976 KB Output is correct
53 Correct 266 ms 3088 KB Output is correct
54 Correct 65 ms 2036 KB Output is correct
55 Correct 144 ms 3008 KB Output is correct
56 Correct 81 ms 3368 KB Output is correct
57 Correct 106 ms 3064 KB Output is correct
58 Correct 274 ms 3048 KB Output is correct
59 Correct 65 ms 1928 KB Output is correct
60 Correct 97 ms 2048 KB Output is correct