Submission #81792

#TimeUsernameProblemLanguageResultExecution timeMemory
81792Just_Solve_The_ProblemCalvinball championship (CEOI15_teams)C++11
20 / 100
1081 ms876 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N = (int)1e4 + 7; int mod = (int)1e9 + 7; int a[N]; int dp[2][N]; int add(int a, int b) { return (a + b) % mod; } int mult(long long a, long long b) { return (a * b) % mod; } int n, mx; int asd[N]; main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; asd[i] = asd[i - 1]; if (a[i] > mx) { mx = a[i]; asd[i]++; } } int ans = 1; for (int i = 1; i <= n; i++) dp[n & 1][i] = 1; ans = add(ans, mult(dp[n & 1][asd[n - 1]], a[n] - 1)); for (int i = n - 1; i >= 1; i--) { for (int j = 0; j <= i; j++) { dp[i & 1][j] = 0; dp[i & 1][j] = add(dp[i & 1][j], dp[i & 1 ^ 1][j + 1]); dp[i & 1][j] = add(dp[i & 1][j], mult(dp[i & 1 ^ 1][j], j)); } ans = add(ans, mult(dp[i & 1][asd[i - 1]], a[i] - 1)); } cout << ans; }

Compilation message (stderr)

teams.cpp:24:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
teams.cpp: In function 'int main()':
teams.cpp:40:42: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
    dp[i & 1][j] = add(dp[i & 1][j], dp[i & 1 ^ 1][j + 1]);
                                        ~~^~~
teams.cpp:41:47: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
    dp[i & 1][j] = add(dp[i & 1][j], mult(dp[i & 1 ^ 1][j], j));
                                             ~~^~~
#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...