Submission #1121979

#TimeUsernameProblemLanguageResultExecution timeMemory
1121979Yusif_NazarliCalvinball championship (CEOI15_teams)C++14
20 / 100
305 ms768 KiB
#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 = 9000; int n; void solve() { cin >> n; vector<ll> a(n + 1); if(n > 14) { for(int i = 1; i <= n; i++) { cin >> a[i]; } vector<ll> prev(n + 1, 0), curr(n + 1, 0); prev[0] = 1; for(int i = 1; i <= n; i++) { for(int j = 0; j <= n; j++) { curr[j] = prev[j] * j % MOD; if(j > 0) curr[j] = (curr[j] + prev[j - 1]) % MOD; } swap(prev, curr); } ll ans = 0; for(int i = 1; i <= n; i++) { ans = (ans + prev[i]) % MOD; } cout << ans << '\n'; return; } ll res = 1, maxi = 0; for(int i = 1; i <= n; i++) { cin >> a[i]; for(int j = 1; j < a[i]; j++) { res = (res + j * res % MOD) % 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...