Submission #255137

#TimeUsernameProblemLanguageResultExecution timeMemory
255137baboTeams (CEOI11_tea)C++14
0 / 100
316 ms51704 KiB
#include <bits/stdc++.h> #define L long long using namespace std; L n; struct S{ L a,ord; }a[1000010]; bool operator<(S a,S b){ return a.a<b.a; } L ma[1000010],mad[1000010],bck[1000010]; int main() { scanf("%lld",&n); L i; for(i=1;i<=n;i++) { scanf("%lld",&a[i].a); a[i].ord=i; } sort(a+1,a+n+1); for(i=1;i<=n;i++) { ma[i]=ma[i-1]; mad[i]=mad[i-1]; if(a[i].a>i) continue; if(ma[i]<=ma[i-a[i].a]+1) { ma[i]=ma[i-a[i].a]+1; mad[i]=i; bck[i]=mad[i-a[i].a]; } } printf("%lld\n",ma[n]); L temp=n; while(temp) { printf("%lld ",temp-bck[temp]); for(i=bck[temp]+1;i<=temp;i++) printf("%lld ",a[i].ord); puts(""); temp=bck[temp]; } }

Compilation message (stderr)

tea.cpp: In function 'int main()':
tea.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&n);
  ~~~~~^~~~~~~~~~~
tea.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&a[i].a);
   ~~~~~^~~~~~~~~~~~~~~~
#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...