Submission #298190

#TimeUsernameProblemLanguageResultExecution timeMemory
298190evpipisTeams (CEOI11_tea)C++11
0 / 100
2594 ms17212 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define mp make_pair typedef long long ll; typedef pair<int, int> ii; const int len = 1e6+5, inf = 1e9; int opt[len], dp[len]; ii arr[len]; int main(){ int n; scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &arr[i].fi), arr[i].se = i; sort(arr+1, arr+1+n); for (int i = 1; i <= n; i++){ dp[i] = -inf; for (int j = 0; j <= i-arr[i].fi; j++) if (dp[j] != -inf && dp[j]+1 >= dp[i]) dp[i] = dp[j]+1, opt[i] = j; } printf("%d\n", dp[n]); int i = n; while (i > 0){ int j = opt[i]; printf("%d", i-j); while (i > j){ printf(" %d", arr[i].se); i--; } printf("\n"); } return 0; }

Compilation message (stderr)

tea.cpp: In function 'int main()':
tea.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
tea.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |         scanf("%d", &arr[i].fi), arr[i].se = 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...