제출 #530723

#제출 시각아이디문제언어결과실행 시간메모리
530723Yazan_AlattarCalvinball championship (CEOI15_teams)C++14
60 / 100
1084 ms65540 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define F first #define S second #define pb push_back #define endl "\n" #define all(x) x.begin(), x.end() const int M = 10007; const ll inf = 2e9; const ll mod = 1e6 + 7; const double pi = acos(-1); const int dx[] = {0, -1, 0, 1}, dy[] = {1, 0, -1, 0}; const int block = 320; ll n, a[M], dp[M][M], pref[M], ans = 1; ll solve(int i, int team){ if(i < 1 || team > n) return 0; if(i == n) return 1; ll &ret = dp[i][team]; if(ret != -1) return ret; ret = 0; for(int j = 1; j <= team + 1; ++j) ret = (ret + solve(i + 1, max(team, j))) % mod; return ret; } int main(){ cin >> n; for(int i = 1; i <= n; ++i) cin >> a[i], pref[i] = max(pref[i - 1], a[i]); for(int i = 0; i <= n; ++i) for(int j = 0; j <= n; ++j) dp[i][j] = -1; for(int i = 1; i <= n; ++i) for(ll j = 1; j < a[i]; ++j) ans = (ans + solve(i, max(pref[i - 1], j))) % mod; cout << ans << endl; 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...