Submission #392674

#TimeUsernameProblemLanguageResultExecution timeMemory
392674Ruxandra985Teams (CEOI11_tea)C++14
50 / 100
20 ms424 KiB
#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)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...