Submission #873338

#TimeUsernameProblemLanguageResultExecution timeMemory
873338bobbilykingCalvinball championship (CEOI15_teams)C++17
0 / 100
42 ms65536 KiB
#pragma GCC target ("avx2") #pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #include<bits/stdc++.h> #include<math.h> using namespace std; typedef long long int ll; typedef long double ld; typedef pair<ll, ll> pl; #define K first #define V second #define G(x) ll x; cin >> x; #define GD(x) ld x; cin >> x; #define GS(s) string s; cin >> s; #define EX(x) { cout << x << '\n'; exit(0); } #define A(a) (a).begin(), (a).end() #define F(i, l, r) for (ll i = (l); i < r; ++i) #define NN 10010 #define M 1000007 // 998244353 ll dp[NN][NN]; int main(){ // freopen("a.in", "r", stdin); // freopen("a.out", "w", stdout); ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); fill(dp[0], dp[0]+NN, 1ll); F(i, 1, NN) F(l, 1, NN-1) { dp[i][l] = (l * dp[i-1][l] + dp[i-1][l+1])%M; } ll mx = 1; ll answer = 1; G(n) for (ll left = n-1; left >= 0; --left) { G(x) if (x <= mx) { // max didn't change, so normal answer = (answer + (x-1) * dp[left][mx])%M; } else { // max changes at the last second; assert(mx + 1 == x); answer = (answer + mx * dp[left][mx])%M; } mx = max(mx, x); } cout << answer << '\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...