| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 816591 | gun_gan | Lasers (NOI19_lasers) | C++17 | 205 ms | 15272 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 <= L) vv.push_back({lst + 1, L});
}
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 = max(rg, r);
}
ans += rg - lf + 1;
cout << ans << '\n';
}| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
