# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
234722 | 2020-05-25T10:54:11 Z | Goolakh | Calvinball championship (CEOI15_teams) | C++17 | 371 ms | 736 KB |
// Do you knOW what it feels like? // To be TorTured by your own MinD? // I don't wanna feel the PAIN. // I BeG you to KILL me, pleASE... #include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O2") #pragma GCC optimize("unroll-loops") //#pragma GCC optimize("Os") #define F first #define S second #define pb push_back #define SZ(x) (ll)(x.size()) #define all(x) x.begin(),x.end() typedef int ll; typedef pair<ll,ll> pll; //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const ll maxn=1e4+10, lg=20, mod=1e9+7, inf=1e18; ll n; long long dp[2][maxn],ans=1; pll ad[maxn]; int main(){ ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0); cin>>n; ll mx=0; for(int i=1;i<=n;i++){ ll x; cin>>x; ad[n-i]={mx,x-1}; //cout<<n-i<<' '<<mx<<' '<<x-1<<endl; mx=max(mx,x); } for(int j=0;j<=n;j++) dp[0][j]=1; for(int ii=1,i,gi;ii<=n;ii++){ i=ii%2; gi=1-i; ans+=dp[gi][ad[ii-1].F]*ad[ii-1].S%mod, ans%=mod; for(int j=1;j<=n;j++) dp[i][j]=((dp[gi][j]*j%mod)+dp[gi][j-1])%mod; } cout<<ans; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Incorrect | 5 ms | 384 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 384 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 350 ms | 620 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 97 ms | 632 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 371 ms | 736 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |