Submission #274680

#TimeUsernameProblemLanguageResultExecution timeMemory
274680arnold518Teams (CEOI11_tea)C++14
50 / 100
2586 ms18040 KiB
#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}; memo[i]=-1; for(int j=0; i-j>=B[i].first; 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)

tea.cpp: In function 'int main()':
tea.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |  scanf("%d", &N);
      |  ~~~~~^~~~~~~~~~
tea.cpp:19:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |  for(int i=1; i<=N; i++) scanf("%d", &A[i]), B[i]={A[i], i};
      |                          ~~~~~^~~~~~~~~~~~~
#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...