답안 #816570

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
816570 2023-08-09T05:44:44 Z makanhulia Lasers (NOI19_lasers) C++17
10 / 100
47 ms 6324 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MX = 5e5 + 5;
int R, L;

vector<pair<int,int>> vv;

int main() {
      cin.tie(0); ios_base::sync_with_stdio(0);

      cin >> L >> R;
      for(int i = 0; i < R; i++) {
            int x;
            cin >> x;

            vector<int> v;
            vector<pair<int,int>> ranges;

            int sum = 0;
            for(int j = 0; j < x; j++) {
                  int k;
                  cin >> k;
                  v.push_back(k);
                  sum += k;
            }

            int l = 1, r = L - sum; // ga ke cover

            ranges.push_back({l, r});

            for(int j = 0; j < x; j++) {
                  l += v[j];
                  r += v[j];

                  ranges.push_back({l, r});
            }

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

            set<int> open;
            int lst = 0;
            for(auto [l, r] : ranges) {
                  while(!open.empty() && *open.begin() < l) {
                        open.erase(open.begin());
                  }

                  if(open.empty()) {
                        if(l - 1 >= lst + 1) {
                              vv.push_back({lst + 1, l - 1}); // selalu ke cover
                        }
                  }

                  open.insert(r);
                  lst = r;
            }

            if(lst + 1 <= sum) vv.push_back({lst + 1, sum});
      }

      sort(vv.begin(), vv.end());
      set<int> open;
      
      int ans = 0, lf = 1, rg = 0;

      for(auto [l, r] : vv) {
            while(!open.empty() && *open.begin() < l) {
                  open.erase(open.begin());
            }

            if(open.empty()) {
                  ans += rg - lf + 1;
                  lf = l, rg = r;
            }

            open.insert(r);
            rg = r;
      }

      ans += rg - lf + 1;

      cout << ans << '\n';
}
# 결과 실행 시간 메모리 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 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
# 결과 실행 시간 메모리 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 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 1 ms 340 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 47 ms 6324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 47 ms 6324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 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 1 ms 340 KB Output isn't correct
12 Halted 0 ms 0 KB -