Submission #95886

#TimeUsernameProblemLanguageResultExecution timeMemory
95886popovicirobertCalvinball championship (CEOI15_teams)C++14
10 / 100
151 ms580 KiB
#include <bits/stdc++.h> #define lsb(x) (x & (-x)) #define ll long long #define ull unsigned long long #define ld long double // 217 // 44 using namespace std; const int MOD = (int) 1e6 + 7; const int MAXN = 10005; inline void mod(int &x) { if(x >= MOD) x -= MOD; } int arr[MAXN + 1], mx[MAXN + 1]; int dp[2][MAXN + 1]; int main() { //ifstream cin("A.in"); //ofstream cout("A.out"); int i, j, n; ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> n; for(i = 1; i <= n; i++) { cin >> arr[i]; mx[i] = max(mx[i - 1], arr[i]); } for(i = 1; i <= mx[n]; i++) { dp[n & 1][i] = i + 1; } int ans = arr[n] - 1; for(i = n - 1; i >= 1; i--) { for(j = 1; j <= mx[i]; j++) { dp[i & 1][j] = (1LL * dp[1 - i & 1][j] * (j + 1) + dp[1 - i & 1][j + 1]) % MOD; //cerr << dp[i & 1][j] << " "; } //cerr << "\n\n"; int cur = 0; for(j = 1; j < arr[i]; j++) { cur += dp[1 - i & 1][mx[i - 1]]; mod(cur); } ans += cur; mod(ans); } cout << (ans + 1) % MOD; //cin.close(); //cout.close(); return 0; }

Compilation message (stderr)

teams.cpp: In function 'int main()':
teams.cpp:39:40: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
             dp[i & 1][j] = (1LL * dp[1 - i & 1][j] * (j + 1) + dp[1 - i & 1][j + 1]) % MOD;
                                      ~~^~~
teams.cpp:39:69: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
             dp[i & 1][j] = (1LL * dp[1 - i & 1][j] * (j + 1) + dp[1 - i & 1][j + 1]) % MOD;
                                                                   ~~^~~
teams.cpp:45:25: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
             cur += dp[1 - i & 1][mx[i - 1]];
                       ~~^~~
#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...