| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1301249 | Thanhs | Lasers (NOI19_lasers) | C++20 | 92 ms | 7872 KiB |
#pragma GCC optimze("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define name "TENBAI"
#define fi first
#define se second
#define endl '\n'
#define setmin(x, y) x = min((x), (y))
#define setmax(x, y) x = max((x), (y))
#define sqr(x) ((x) * (x))
#define all(x) x.begin(), x.end()
mt19937 hdp(chrono::high_resolution_clock::now().time_since_epoch().count());
int rand(int l, int r){return l + ((hdp() % (r - l + 1)) + r - l + 1) % (r - l + 1);}
int L, n;
vector<pair<int, int>> V;
bool its(pair<int, int> x, pair<int, int> y)
{
return min(x.se, y.se) >= max(x.fi, y.fi);
}
void solve()
{
cin >> L >> n;
while (n--)
{
int t;
cin >> t;
vector<int> a;
while (t--)
{
int x;
cin >> x;
a.push_back(x);
}
int miss = L - accumulate(all(a), 0);
vector<pair<int, int>> v;
int sum = 0;
v.push_back({sum + 1, sum + miss});
for (int x : a)
{
sum += x;
v.push_back({sum + 1, sum + miss});
}
int pr = 0;
sort(all(v));
for (int i = 0; i < v.size(); i++)
{
int l = v[i].fi, r = v[i].se;
int j = i;
while (j + 1 < v.size() && its({l, r}, v[j + 1]))
{
j++;
setmin(l, v[j].fi);
setmax(r, v[j].se);
}
i = j;
if (pr + 1 <= l - 1)
V.emplace_back(pr + 1, l - 1);
pr = r;
}
if (pr + 1 <= L)
V.emplace_back(pr + 1, L);
}
int pr = 0, ans = 0;
sort(all(V));
for (int i = 0; i < V.size(); i++)
{
int l = V[i].fi, r = V[i].se;
int j = i;
while (j + 1 < V.size() && its({l, r}, V[j + 1]))
{
j++;
setmin(l, V[j].fi);
setmax(r, V[j].se);
}
i = j;
ans += l - pr - 1;
pr = r;
}
ans += L - pr;
cout << L - ans;
}
signed main()
{
if (fopen("in.txt", "r"))
{
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
}
else if (fopen(name".inp", "r"))
{
freopen(name".inp", "r", stdin);
freopen(name".out", "w", stdout);
}
ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
int tc = 1;
// cin >> tc;
while (tc--)
solve();
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
