# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
209762 | Alexa2001 | Solar Storm (NOI20_solarstorm) | C++17 | 221 ms | 113248 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>
using namespace std;
using ll = long long;
const int Nmax = 1e6 + 5, lg = 20;
// 15 : 38
int go[lg+1][Nmax], n, S, deploy[Nmax];
ll coef[Nmax], d[Nmax], K;
const int bsize = 1 << 18;
char buffer[bsize+2]; int cursor;
static inline void init_read()
{
fread(buffer, 1, bsize, stdin), cursor = 0;
}
template<typename T>
void read(T &x)
{
x = 0;
while(!isdigit(buffer[cursor]))
{
++cursor;
if(cursor == bsize) init_read();
}
while(isdigit(buffer[cursor]))
{
x = x * 10 + buffer[cursor] - '0';
++cursor;
if(cursor == bsize) init_read();
}
}
int main()
{
// freopen("input", "r", stdin);
cin.sync_with_stdio(false); cin.tie(0);
init_read();
read(n); read(S); read(K);
int i;
for(i=2; i<=n; ++i)
{
read(d[i]);
d[i] += d[i-1];
}
for(i=1; i<=n; ++i) read(coef[i]), coef[i] += coef[i-1];
d[n+1] = 1e18;
int j, k;
j = 1; k = 2;
for(i=1; i<=n; ++i)
{
while(d[j+1] - d[i] <= K) ++j;
while(d[k] - d[j] <= K) ++k;
go[0][i] = k;
deploy[i] = j;
}
go[0][n+1] = n+1;
for(j=1; j<=lg; ++j)
for(i=1; i<=n+1; ++i)
go[j][i] = go[j-1][go[j-1][i]];
ll ans = -1;
int start, finish;
for(i=1; i<=n; ++i)
{
int to = i;
for(j=0; j<=lg; ++j)
if(S & (1<<j))
to = go[j][to];
ll curr = coef[to-1] - coef[i-1];
if(curr > ans)
ans = curr, start = i, finish = to - 1;
}
vector<int> Ans;
while(start <= finish)
{
Ans.push_back(deploy[start]);
start = go[0][start];
}
cout << Ans.size() << '\n';
for(auto it : Ans) cout << it << ' ';
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |