Submission #256954

#TimeUsernameProblemLanguageResultExecution timeMemory
256954kimbj0709Calvinball championship (CEOI15_teams)C++14
100 / 100
204 ms760 KiB
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define int long long #define mod 1000007 #define maxn 10050 int32_t main() { ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); int n; int input; cin >> n; vector<int> vect1(n+1); vector<int> prefix(n+1,0); for(int i=1;i<=n;i++){ cin >> vect1[i]; prefix[i] = vect1[i]; } for(int i=1;i<prefix.size();i++){ prefix[i] = max(prefix[i],prefix[i-1]); } int dp[2][maxn]; for(int i=1;i<n;i++){ dp[0][i] = 1; } int ans = 0; for(int i=1;i<n;i++){ int curr = (i%2),bef = ((i-1)%2); for(int j=1;j<=n;j++){ dp[curr][j] = j*dp[bef][j]+dp[bef][j+1]; dp[curr][j] %= mod; } ans += (vect1[n-i]-1)*dp[curr][prefix[n-i-1]]; ans %= mod; } ans += vect1[n]; ans %= mod; cout << ans; }

Compilation message (stderr)

teams.cpp: In function 'int32_t main()':
teams.cpp:19:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=1;i<prefix.size();i++){
               ~^~~~~~~~~~~~~~
teams.cpp:11:7: warning: unused variable 'input' [-Wunused-variable]
   int input;
       ^~~~~
#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...