제출 #1121814

#제출 시각아이디문제언어결과실행 시간메모리
1121814raul2008487Calvinball championship (CEOI15_teams)C++17
10 / 100
21 ms9040 KiB
#include<bits/stdc++.h> #define ll long long #define pb push_back #define in insert #define fi first #define se second #define vl vector<ll> #define all(v) v.begin(), v.end() #define endl "\n" using namespace std; const int sz = 1e3 + 5; /// mind this const int MAX = 2e6 + 123; const int BS = 61; const int mod = 1e6 + 7; ll dp[sz][sz]; ll bp(ll a, ll b){ ll res = 1; a %= mod; while(b){ if(b & 1){ res = (res * a) % mod; } a = (a * a) % mod; b >>= 1; } return res; } void solve(){ ll n, i, j, hi = 0, ans = 0; cin >> n; vl v(n + 1), fp(n + 1, -1); for(i = 1; i <= n; i++){ cin >> v[i]; hi = max(hi, v[i]); if(fp[v[i]] == -1 ){ fp[v[i]] = i; } dp[i][1] = 1; } for(i = 1; i <= n; i ++){ for(j = 2; j <= hi; j++){ if(i < fp[j]){break;} dp[i][j] = (dp[i - 1][j - 1] + (dp[i - 1][j] * j) % mod) % mod; } } for(i = 1; i <= hi; i++){ ans = (ans + dp[n][i]) % mod; } cout << ans << endl; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll t = 1; // cin >> t; while(t--){ solve(); } } /* */
#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...