# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
699111 | DennisTran | Lasers (NOI19_lasers) | C++17 | 434 ms | 23476 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O2")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FOD(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define TIME (1.0 * clock() / CLOCKS_PER_SEC)
#define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
#define ii pair <int, int>
#define fi first
#define se second
using namespace std;
const int MAXN = 5e5 + 5;
int L, R, a[MAXN], sum[MAXN];
map <int, int> mp;
void solve(void) {
cin >> L >> R;
FOR(i, 1, R) {
int n; cin >> n;
int D = L;
FOR(i, 1, n) cin >> a[i], sum[i] = sum[i - 1] + a[i], D -= a[i];
sum[n + 1] = L;
FOR(i, 0, n) {
int l = sum[i] + D + 1;
int r = sum[i + 1];
if (r >= l) mp[l]++, mp[r + 1]--;
//if (r >= l) cout << l << ' ' << r << '\n';
}
//cout << '\n';
}
int ans = 0, sum = 0;
for (auto it = mp.begin(); it != mp.end() && next(it) != mp.end(); it++) {
sum += it -> se;
if (sum > 0) ans += next(it) -> fi - it ->fi;
}
cout << ans;
}
signed main(void) {
ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
file("LASERS");
//int T; cin >> T; while (T--)
solve();
cerr << "Time elapsed: " << TIME << " s.\n";
return (0 ^ 0);
}
Compilation message (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... |