제출 #1121984

#제출 시각아이디문제언어결과실행 시간메모리
1121984Haciyev12Calvinball championship (CEOI15_teams)C++14
0 / 100
60 ms65536 KiB
#include "bits/stdc++.h" #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define ll long long #define pb push_back #define in insert #define F first #define S second #define vll vector<ll> #define all(v) v.begin(),v.end() #define endl '\n' #define pii pair<ll,ll> using namespace std; const ll INF =1e18, mod = 1e6 + 7, N = 1e4 + 50; int maxi,q = 1; int n; int cnt(int w, int e){ if(e > n){ return 0; } if(w == 0){ return 1; } return(((cnt(w - 1, e) * e ) % mod) + (cnt(w - 1, e + 1) % mod) ) % mod; } vector<vector<int>>dp(N, vector<int>(N,0)); int a[N]; void solve(){ cin >> n; if(n > 14){ for(int i =1; i<= n; i++){ cin >> a[i]; } dp[0][0] = 1; for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ dp[i][j] = ((dp[i - 1][j] * j % mod) + dp[i - 1][j- 1]) % mod; } } ll ans = 0; for(int i = 1; i <= n; i++){ ans += dp[n][i] % mod; ans %= mod; } cout << ans % mod; return; } for(int i = 1; i <= n; i++){ cin >> a[i];//1 2 2 for(int j = 1; j < a[i]; j++){ q = (q + cnt(n - i,maxi)) % mod; /// space element }/// 1 , 2 0,2 maxi = max(a[i], maxi); } cout << q % mod << endl; } int main(){ fast; ll t = 1; // cin >> t; while(t--){ 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...