# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
668774 | vuavisao | Lasers (NOI19_lasers) | C++14 | 18 ms | 3956 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.
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define ll long long
using namespace std;
template<typename Lhs, typename Rhs> inline void Max_self(Lhs &a, Rhs b) { a = (a > b ? a : b); }
template<typename Lhs, typename Rhs> inline void Min_self(Lhs &a, Rhs b) { a = (a < b ? a : b); }
const int N = 5e5 + 10;
int LEN, n;
vector<vector<int>> door;
namespace sub2 {
bool check() {
for(int i = 0; i < n; ++ i) if(door[i].size() != 2) return false;
return true;
}
void solve() {
int best = 0;
for(int i = 0; i < n; ++ i) {
Max_self(best, door[i][0]);
}
cout << max(0, 2 * best - LEN);
}
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if (fopen("lasers.inp", "r")) {
freopen("lasers.inp", "r", stdin);
freopen("lasers.out", "w", stdout);
}
cin >> LEN >> n;
for(int i = 1; i <= n; ++ i) {
int cnt; cin >> cnt;
vector<int> tmp(cnt + 1);
for(int j = 1; j <= cnt; ++ j) cin >> tmp[j];
door.push_back(tmp);
}
if(sub2::check()) {
sub2::solve();
return 0;
}
assert(false);
// if(sub4::check()) {
// sub4::solve();
// return 0;
// }
return 0;
}
/// Code by vuavisao
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... |