Submission #244452

#TimeUsernameProblemLanguageResultExecution timeMemory
244452cheehengCalvinball championship (CEOI15_teams)C++14
70 / 100
741 ms8440 KiB
#include <bits/stdc++.h> using namespace std; const int MOD = 1000007; int A[1005]; int memo[1005][1005][2]; int n; int dp(int i, int cur_max, int same_so_far){ if(i == n){ return 1; }else if(memo[i][cur_max][same_so_far] != -1){ return memo[i][cur_max][same_so_far]; }else{ long long ans = 0; if(same_so_far){ for(int j = 1; j <= A[i]; j ++){ ans += dp(i+1, max(cur_max, j), j == A[i]); } }else{ for(int j = 1; j <= cur_max+1; j ++){ ans += dp(i+1, max(cur_max, j), 0); } } return memo[i][cur_max][same_so_far] = ans%MOD; } } int main(){ scanf("%d", &n); for(int i = 0; i < n; i ++){ scanf("%d", &A[i]); } memset(memo, -1, sizeof(memo)); printf("%d", dp(0, 0, 1)); return 0; }

Compilation message (stderr)

teams.cpp: In function 'int main()':
teams.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
teams.cpp:37:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &A[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...