# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
392674 | Ruxandra985 | Teams (CEOI11_tea) | C++14 | 20 ms | 424 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>
#define DIMN 5010
using namespace std;
struct idk{
int ech , ok , sz , fth;
} dp[DIMN];
pair <int , int> v[DIMN];
int main()
{
FILE *fin = stdin;
FILE *fout = stdout;
int n , i , j , now;
fscanf (fin,"%d",&n);
for (i = 1 ; i <= n ; i++){
fscanf (fin,"%d",&v[i].first);
v[i].second = i;
}
sort (v + 1 , v + n + 1);
dp[0].ok = 1;
for (i = 1 ; i <= n ; i++){
for (j = i - v[i].first ; j >= 0 ; j--){
if (!dp[j].ok)
continue;
if (dp[j].ech + 1 > dp[i].ech){
dp[i].ech = dp[j].ech + 1;
dp[i].ok = 1;
dp[i].sz = max(i - j , dp[j].sz);
dp[i].fth = j;
}
else if (dp[j].ech + 1 == dp[i].ech && max(i - j , dp[j].sz) < dp[i].sz){
dp[i].ech = dp[j].ech + 1;
dp[i].ok = 1;
dp[i].sz = max(i - j , dp[j].sz);
dp[i].fth = j;
}
}
}
fprintf (fout,"%d\n" , dp[n].ech);
now = n;
while (now){
fprintf (fout,"%d ", now - dp[now].fth);
for (i = now ; i > dp[now].fth ; i--)
fprintf (fout,"%d ",v[i].second);
fprintf (fout,"\n");
now = dp[now].fth;
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |