Submission #392673

# Submission time Handle Problem Language Result Execution time Memory
392673 2021-04-21T13:20:22 Z Ruxandra985 Teams (CEOI11_tea) C++14
0 / 100
10 ms 716 KB
#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++){

        if (i == 1)
            printf ("a");

        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

tea.cpp: In function 'int main()':
tea.cpp:17:12: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |     fscanf (fin,"%d",&n);
      |     ~~~~~~~^~~~~~~~~~~~~
tea.cpp:19:16: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |         fscanf (fin,"%d",&v[i].first);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Expected integer, but "a1" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 308 KB Expected integer, but "a2" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Expected integer, but "a5" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 460 KB Expected integer, but "a5" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 332 KB Expected integer, but "a3" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3 ms 588 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3 ms 588 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3 ms 588 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3 ms 588 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5 ms 716 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -