Submission #815858

# Submission time Handle Problem Language Result Execution time Memory
815858 2023-08-09T01:25:18 Z christinelynn Lasers (NOI19_lasers) C++17
100 / 100
249 ms 39252 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second

const int N = 5e5 + 5;

int x[N], sum[N];
vector<int> a[N];
vector<pair<int, int>> v, ans1, ans2;

int main() { 
    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    int l, r;
    cin >> l >> r;
    for (int i = 1; i <= r; i++) {
        cin >> x[i];
        for (int j = 0; j < x[i]; j++) {
            int x2;
            cin >> x2;
            a[i].push_back(x2);
            sum[i] += x2;
        }
    }
    for (int i = 1; i <= r; i++) {
        v.clear();
        if (sum[i] == l) {
            ans1.push_back({1, l});
            break;
        }
        int sum1 = 0, sum2 = sum[i];
        v.push_back({sum1 + 1, l - sum2});
        for (int j = 0; j < x[i]; j++) {
            sum1 += a[i][j], sum2 -= a[i][j];
            v.push_back({sum1 + 1, l - sum2});
        }
        for (int j = 1; j < (int)v.size(); j++) {
            if (v[j].fi <= v[j - 1].se) continue;
            ans1.push_back({v[j - 1].se + 1, v[j].fi - 1});
        }
        // cout << i << "flaw\n";
        // for (auto j : v) cout << j.fi << " " << j.se << "fkwoa\n";
    }
    sort(ans1.begin(), ans1.end());
    // for (auto i : ans1) cout << i.fi << " " << i.se << "dkawop\n";
    for (auto y : ans1) {
        if (ans2.empty()) ans2.push_back(y);
        else {
            if (y.fi <= ans2.back().se) ans2.back().se = max(ans2.back().se, y.se);
            else ans2.push_back(y);
        }
    }
    int ans = 0;
    for (auto y : ans2) ans += y.se - y.fi + 1;
    cout << ans << "\n";
}  
# Verdict Execution time Memory Grader output
1 Correct 6 ms 11988 KB Output is correct
2 Correct 6 ms 11988 KB Output is correct
3 Correct 6 ms 11988 KB Output is correct
4 Correct 6 ms 11956 KB Output is correct
5 Correct 6 ms 12056 KB Output is correct
6 Correct 6 ms 12064 KB Output is correct
7 Correct 5 ms 11988 KB Output is correct
8 Correct 6 ms 11988 KB Output is correct
9 Correct 6 ms 12028 KB Output is correct
10 Correct 6 ms 11988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 11988 KB Output is correct
2 Correct 6 ms 11988 KB Output is correct
3 Correct 6 ms 11988 KB Output is correct
4 Correct 6 ms 11956 KB Output is correct
5 Correct 6 ms 12056 KB Output is correct
6 Correct 6 ms 12064 KB Output is correct
7 Correct 5 ms 11988 KB Output is correct
8 Correct 6 ms 11988 KB Output is correct
9 Correct 6 ms 12028 KB Output is correct
10 Correct 6 ms 11988 KB Output is correct
11 Correct 6 ms 11988 KB Output is correct
12 Correct 212 ms 31132 KB Output is correct
13 Correct 6 ms 11988 KB Output is correct
14 Correct 7 ms 11988 KB Output is correct
15 Correct 5 ms 11988 KB Output is correct
16 Correct 6 ms 12104 KB Output is correct
17 Correct 245 ms 33692 KB Output is correct
18 Correct 6 ms 11988 KB Output is correct
19 Correct 6 ms 11988 KB Output is correct
20 Correct 5 ms 11988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 17872 KB Output is correct
2 Correct 19 ms 13388 KB Output is correct
3 Correct 19 ms 13396 KB Output is correct
4 Correct 62 ms 20092 KB Output is correct
5 Correct 30 ms 16088 KB Output is correct
6 Correct 58 ms 20512 KB Output is correct
7 Correct 7 ms 12192 KB Output is correct
8 Correct 65 ms 19904 KB Output is correct
9 Correct 35 ms 16832 KB Output is correct
10 Correct 64 ms 19812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 11988 KB Output is correct
2 Correct 5 ms 11988 KB Output is correct
3 Correct 6 ms 11988 KB Output is correct
4 Correct 7 ms 11988 KB Output is correct
5 Correct 6 ms 11980 KB Output is correct
6 Correct 6 ms 12056 KB Output is correct
7 Correct 6 ms 12060 KB Output is correct
8 Correct 6 ms 12060 KB Output is correct
9 Correct 6 ms 12116 KB Output is correct
10 Correct 6 ms 11988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 17872 KB Output is correct
2 Correct 19 ms 13388 KB Output is correct
3 Correct 19 ms 13396 KB Output is correct
4 Correct 62 ms 20092 KB Output is correct
5 Correct 30 ms 16088 KB Output is correct
6 Correct 58 ms 20512 KB Output is correct
7 Correct 7 ms 12192 KB Output is correct
8 Correct 65 ms 19904 KB Output is correct
9 Correct 35 ms 16832 KB Output is correct
10 Correct 64 ms 19812 KB Output is correct
11 Correct 6 ms 11988 KB Output is correct
12 Correct 5 ms 11988 KB Output is correct
13 Correct 6 ms 11988 KB Output is correct
14 Correct 7 ms 11988 KB Output is correct
15 Correct 6 ms 11980 KB Output is correct
16 Correct 6 ms 12056 KB Output is correct
17 Correct 6 ms 12060 KB Output is correct
18 Correct 6 ms 12060 KB Output is correct
19 Correct 6 ms 12116 KB Output is correct
20 Correct 6 ms 11988 KB Output is correct
21 Correct 220 ms 37896 KB Output is correct
22 Correct 34 ms 14008 KB Output is correct
23 Correct 22 ms 13580 KB Output is correct
24 Correct 73 ms 18952 KB Output is correct
25 Correct 220 ms 37856 KB Output is correct
26 Correct 62 ms 16996 KB Output is correct
27 Correct 29 ms 13856 KB Output is correct
28 Correct 221 ms 37880 KB Output is correct
29 Correct 219 ms 37956 KB Output is correct
30 Correct 61 ms 16552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 11988 KB Output is correct
2 Correct 6 ms 11988 KB Output is correct
3 Correct 6 ms 11988 KB Output is correct
4 Correct 6 ms 11956 KB Output is correct
5 Correct 6 ms 12056 KB Output is correct
6 Correct 6 ms 12064 KB Output is correct
7 Correct 5 ms 11988 KB Output is correct
8 Correct 6 ms 11988 KB Output is correct
9 Correct 6 ms 12028 KB Output is correct
10 Correct 6 ms 11988 KB Output is correct
11 Correct 6 ms 11988 KB Output is correct
12 Correct 212 ms 31132 KB Output is correct
13 Correct 6 ms 11988 KB Output is correct
14 Correct 7 ms 11988 KB Output is correct
15 Correct 5 ms 11988 KB Output is correct
16 Correct 6 ms 12104 KB Output is correct
17 Correct 245 ms 33692 KB Output is correct
18 Correct 6 ms 11988 KB Output is correct
19 Correct 6 ms 11988 KB Output is correct
20 Correct 5 ms 11988 KB Output is correct
21 Correct 58 ms 17872 KB Output is correct
22 Correct 19 ms 13388 KB Output is correct
23 Correct 19 ms 13396 KB Output is correct
24 Correct 62 ms 20092 KB Output is correct
25 Correct 30 ms 16088 KB Output is correct
26 Correct 58 ms 20512 KB Output is correct
27 Correct 7 ms 12192 KB Output is correct
28 Correct 65 ms 19904 KB Output is correct
29 Correct 35 ms 16832 KB Output is correct
30 Correct 64 ms 19812 KB Output is correct
31 Correct 6 ms 11988 KB Output is correct
32 Correct 5 ms 11988 KB Output is correct
33 Correct 6 ms 11988 KB Output is correct
34 Correct 7 ms 11988 KB Output is correct
35 Correct 6 ms 11980 KB Output is correct
36 Correct 6 ms 12056 KB Output is correct
37 Correct 6 ms 12060 KB Output is correct
38 Correct 6 ms 12060 KB Output is correct
39 Correct 6 ms 12116 KB Output is correct
40 Correct 6 ms 11988 KB Output is correct
41 Correct 220 ms 37896 KB Output is correct
42 Correct 34 ms 14008 KB Output is correct
43 Correct 22 ms 13580 KB Output is correct
44 Correct 73 ms 18952 KB Output is correct
45 Correct 220 ms 37856 KB Output is correct
46 Correct 62 ms 16996 KB Output is correct
47 Correct 29 ms 13856 KB Output is correct
48 Correct 221 ms 37880 KB Output is correct
49 Correct 219 ms 37956 KB Output is correct
50 Correct 61 ms 16552 KB Output is correct
51 Correct 32 ms 14152 KB Output is correct
52 Correct 245 ms 39152 KB Output is correct
53 Correct 249 ms 39076 KB Output is correct
54 Correct 55 ms 15660 KB Output is correct
55 Correct 138 ms 20060 KB Output is correct
56 Correct 72 ms 18672 KB Output is correct
57 Correct 98 ms 18028 KB Output is correct
58 Correct 245 ms 39252 KB Output is correct
59 Correct 60 ms 15824 KB Output is correct
60 Correct 87 ms 17140 KB Output is correct