Submission #642232

# Submission time Handle Problem Language Result Execution time Memory
642232 2022-09-19T02:23:03 Z christinelynn Lasers (NOI19_lasers) C++17
0 / 100
29 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 = -1, right = -1;

    for(int i = 0; i < seg.size(); i++){
        if(r < seg[i].first){
            ans += (r - l);
            l = seg[i].first;
        }

        r = max(r, seg[i].second);
    }

    ans += (r - l);

    cout << ans << '\n';

    return 0;
}

Compilation message

lasers.cpp: In function 'int main()':
lasers.cpp:36:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(int i = 0; i < seg.size(); i++){
      |                    ~~^~~~~~~~~~~~
lasers.cpp:34:9: warning: unused variable 'left' [-Wunused-variable]
   34 |     int left = -1, right = -1;
      |         ^~~~
lasers.cpp:34:20: warning: unused variable 'right' [-Wunused-variable]
   34 |     int left = -1, right = -1;
      |                    ^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 2912 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 2912 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -