# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
274671 | arnold518 | Teams (CEOI11_tea) | C++14 | 2596 ms | 23220 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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1e6;
const int INF = 987654321;
int N, A[MAXN+10];
pii B[MAXN+10];
pii dp[MAXN+10];
int memo[MAXN+10];
int main()
{
scanf("%d", &N);
for(int i=1; i<=N; i++) scanf("%d", &A[i]), B[i]={A[i], i};
sort(B+1, B+N+1);
for(int i=1; i<=N; i++)
{
dp[i]={-INF, INF};
for(int j=0; i-j>=A[i]; j++)
{
pii t=dp[j];
t.first++; t.second=max(t.second, i-j);
if(t.first>dp[i].first) dp[i]=t, memo[i]=j;
else if(t.first==dp[i].first && t.second<dp[i].second) dp[i]=t, memo[i]=j;
}
}
printf("%d\n", dp[N].first);
int now=N;
while(now)
{
printf("%d ", now-memo[now]);
for(int i=now; i>memo[now]; i--) printf("%d ", B[i].second);
printf("\n"); now=memo[now];
}
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |