Submission #642229

# Submission time Handle Problem Language Result Execution time Memory
642229 2022-09-19T02:20:45 Z makanhulia Lasers (NOI19_lasers) C++17
10 / 100
28 ms 2912 KB
#include <bits/stdc++.h>

using namespace std;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int l, r; cin >> l >> r;
    vector<pair<int, int>>seg;

    for(int i = 1; i <= r; i++){
        int left = 0, right = l;
        int x; cin >> x;
        vector<int>v(x);
        for(int j = 0; j < x; j++){
            cin >> v[j];
            left += v[j];
        }
        left -= v.back();

        for(int j = x - 1; j >= 0; j--){
            int l1 = left, r1 = left + v[j];
            int l2 = right - v[j], r2 = right;
            if(max(l1, l2) < min(r1, r2)){
                seg.emplace_back(max(l1, l2), min(r1, r2));
            }
            if(j) left -= v[j - 1];
            right -= v[j];
        }
    }

    sort(seg.begin(), seg.end());

    int ans = 0;
    int left = 0, right = 0;
    int sz = seg.size();

    while(left < sz && right < sz){
        while(right + 1 < sz && seg[right + 1].first <= seg[right].second) right++;
        ans += (seg[right].second - seg[left].first);
        left = right + 1;
        right = left;
    }

    cout << ans << '\n';

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Incorrect 0 ms 212 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 2912 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 2912 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Incorrect 0 ms 212 KB Output isn't correct
12 Halted 0 ms 0 KB -