Submission #1121962

#TimeUsernameProblemLanguageResultExecution timeMemory
1121962vjudge1Calvinball championship (CEOI15_teams)C++17
30 / 100
70 ms65536 KiB
// Author: RufatM #include <bits/stdc++.h> using namespace std; #define MOD 1000007 #define INF 1e9+7 #define ll long long #define ull unsigned long long #define vi vector<int> #define vii vector<vector<int>> #define mii map<int,int> #define pb push_back #define pii pair<ll,int> #define all(x) (x).begin(),(x).end() #define sz(x) (int)(x).size() #define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) const int N = 10001; ll dp[N][N]; int n; ll maxi = 0; ll count(ll pos, ll max_team) { if(pos > n) return 0; if(pos == 0) return 1; return ((count(pos - 1, max_team) * max_team) % MOD + count(pos - 1, max_team + 1) % MOD) % MOD; } void solve() { cin >> n; vector<ll> a(n + 1); if(n > 14) { for(int i = 1; i <= n; i++) { cin >> a[i]; } memset(dp, 0, sizeof(dp)); 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 = (ans + dp[n][i]) % MOD; } cout << ans << '\n'; return; } ll res = 1; for(int i = 1; i <= n; i++) { cin >> a[i]; for(int j = 1; j < a[i]; j++) { res = (res + count(n - i, maxi)) % MOD; } maxi = max(maxi, a[i]); } cout << res << '\n'; } signed main() { fastio; int 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...