제출 #1121786

#제출 시각아이디문제언어결과실행 시간메모리
1121786aykhnCalvinball championship (CEOI15_teams)C++17
100 / 100
173 ms860 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define inf 0x3F3F3F3F const int B = 1e2 + 5; const int MXN = 1e4 + 5; const int mod = 1e6 + 7; int dp[B][MXN]; int bl[B][MXN]; int cur[MXN], nw[MXN]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, res = 0; cin >> n; int a[n + 1], p[n + 1]; p[0] = 0; for (int i = 1; i <= n; i++) cin >> a[i], p[i] = max(p[i - 1], a[i]); fill(cur + 1, cur + n + 1, 1); for (int i = n - 1; i >= 1; i--) { res = (res + (((a[i + 1] - 1) * cur[p[i]]) % mod)) % mod; for (int j = 1; j <= n; j++) nw[j] = cur[j + 1] + (cur[j] * j) % mod; for (int j = 1; j <= n; j++) cur[j] = nw[j]; } cout << (res + 1) % mod << '\n'; }
#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...