Submission #531357

#TimeUsernameProblemLanguageResultExecution timeMemory
531357sidonCalvinball championship (CEOI15_teams)C++17
100 / 100
242 ms420 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int M = 1e6+7; int32_t main() { int N; cin >> N; int a[N], res{1}; for(int &i : a) cin >> i, --i; vector<int> dp(N+1, 1); for(int i = N; i--; ) { res += a[i] * dp[i ? *max_element(a, a+i) + 1 : 0]; for(int j = 0; j <= N; ++j) dp[j] = ((j + 1 < N ? dp[j + 1] : 0LL) + j * dp[j]) % M; } cout << (res % M); }
#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...