제출 #1121693

#제출 시각아이디문제언어결과실행 시간메모리
1121693MamedovCalvinball championship (CEOI15_teams)C++17
70 / 100
55 ms65536 KiB
#pragma GCC optimize ("O3") #include <bits/stdc++.h> //#include<ext/pb_ds/assoc_container.hpp> //#include<ext/pb_ds/tree_policy.hpp> #define pii pair<int, int> #define piii pair<pii, int> #define vi vector<int> #define vll vector<ll> #define vvi vector<vi> #define vpii vector<pii> #define vvpii vector<vpii> #define f first #define s second #define oo 1000000001 #define eb emplace_back #define pb push_back #define mpr make_pair #define size(v) (int)v.size() #define ln '\n' #define ull unsigned long long #define ll long long #define all(v) v.begin(), v.end() #define iospeed ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) //#define pbase 361549 //#define imod 1073737591 //#define uimod 2147479307u //#define llmod 292187309552789533ll using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //using namespace __gnu_pbds; //template <typename T> //using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; template <typename T> void show(vector<T> &v) { for (T i : v) { cout << i << ' '; } cout << ln; } void solve() { int n; cin >> n; vi a(n + 1); for (int i = 1; i <= n; ++i) { cin >> a[i]; } vvi dp(n + 1, vi(n + 1, 0)); for (int i = 1; i <= n; ++i) { dp[n][i] = 1; } const int mod = 1e6 + 7; for (int i = n - 1; i >= 1; --i) { for (int m = 1; m <= i; ++m) { dp[i][m] = (1ll * m * dp[i + 1][m] + dp[i + 1][m + 1]) % mod; } } int res = 1; int m = a[1]; for (int i = 2; i <= n; ++i) { res = (1ll * (a[i] - 1) * dp[i][m] + res) % mod; m = max(m, a[i]); } cout << res << ln; } int main() { iospeed; solve(); return 0; }
#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...