# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1259434 | phtung | Lasers (NOI19_lasers) | C++20 | 21 ms | 17128 KiB |
#include <bits/stdc++.h>
using namespace std;
#define name "IO"
#define int long long
const int inf = 1e18 + 7;
const int maxn = 5e5 + 5;
int L, R;
vector<int> row[maxn];
void sub1()
{
int len = row[1].back();
if(len <= L / 2)
{
cout << 0 << "\n";
return;
}
int res = len - (L / 2);
if(L % 2)
{
cout << res * 2 - 1 << "\n";
}
else cout << res * 2 << "\n";
}
void sub2()
{
int res = 0;
for(int i = 1; i <= R; i++)
{
int l = row[i][0];
if(l <= L / 2) continue;
int len = l - (L / 2);
if(L % 2) res = max(res, len * 2 - 1);
else res = max(res, len * 2);
}
cout << res << "\n";
}
void solve()
{
cin >> L >> R;
int mxX = 0;
for(int i = 1; i <= R; i++)
{
int x; cin >> x;
mxX = max(mxX, x);
for(int i = 1; i <= x; i++)
{
int len;
cin >> len ;
row[i].push_back(len);
}
}
if(mxX == 1) sub2();
}
signed main()
{
if (fopen (name".INP", "r"))
{
freopen (name".INP", "r", stdin);
freopen (name".OUT", "w", stdout);
}
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
clock_t start = clock();
int t = 1;
while(t--) solve();
std::cerr << "Time: " << clock() - start << "ms\n";
return 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... |