제출 #1133265

#제출 시각아이디문제언어결과실행 시간메모리
1133265ByeWorldCalvinball championship (CEOI15_teams)C++20
100 / 100
360 ms600 KiB
#include <bits/stdc++.h> // #define int long long #define ll long long #define pb push_back #define fi first #define se second #define lf (id<<1) #define rg ((id<<1)|1) #define md ((l+r)>>1) #define ld long double using namespace std; typedef pair<int,int> pii; typedef pair<char,char> pcc; typedef pair<int,pii> ipii; typedef pair<pii,pii> ipiii; const int MAXN = 1e4+10; const int SQRT = 610; const int MAXA = 50; const int MOD = 1e6+7; const int INF = 1e9+10; const int LOG = 21; const ld EPS = 1e-12; int sum(int a, int b){ return (a+b)%MOD; } int mul(int a, int b){ return (1ll*a*b)%MOD; } void chsum(int &a, int b){ a = (a+b)%MOD; } void chmul(int &a, int b){ a = (1ll*a*b)%MOD; } int n, dp[3][MAXN], a[MAXN]; int mx[MAXN]; signed main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n; // cout<<dp[2][2]<< ' '<<dp[1][3]<<" pp\n"; int ans = 1; for(int i=1; i<=n; i++) cin >> a[i]; for(int i=1; i<=n; i++) mx[i] = max(mx[i-1],a[i]); for(int i=0; i<=n; i++) dp[0][i] = 1; for(int i=n; i>=2; i--){ for(int j=1; j<=a[i]-1; j++) chsum(ans, dp[0][max(mx[i-1]+1, j+1)] ); for(int j=1; j<=n; j++){ dp[1][j] = sum(mul(j-1, dp[0][j]), dp[0][j+1]); } for(int j=1; j<=n; j++) dp[0][j] = dp[1][j]; } cout << ans << '\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...