Submission #100674

#TimeUsernameProblemLanguageResultExecution timeMemory
100674win11905Calvinball championship (CEOI15_teams)C++11
100 / 100
97 ms536 KiB
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author win11905 */ #include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() #define vi vector<int> #define iii tuple<int, int, int> #define long long long #define pii pair<int, int> #define x first #define y second using namespace std; const long MOD = 1e6+7, LINF = 1e18 + 1e16; const int INF = 1e9+1; const double EPS = 1e-10; const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1}; const int N = 1e4+5; class calvinball { private: int n; int inp[N]; int dp[N]; public: void solve(istream& cin, ostream& cout) { cin >> n; for(int i = 1; i <= n; ++i) cin >> inp[i]; int mx = 0; for(int i = 1; i <= n; ++i) { for(int j = i; j; --j) dp[j] = (dp[j-1] + 1ll * dp[j] * j) % MOD; dp[mx] += inp[i]-1; mx = max(mx, inp[i]); } int sum = 1; for(int i = 1; i <= n; ++i) sum = (sum + dp[i]) % MOD; cout << sum << endl; } }; class Solver { public: void solve(std::istream& in, std::ostream& out) { calvinball *obj = new calvinball(); obj->solve(in, out); } }; int32_t main() { ios::sync_with_stdio(false); cin.tie(0); Solver solver; std::istream& in(std::cin); std::ostream& out(std::cout); solver.solve(in, out); 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...