Submission #234722

#TimeUsernameProblemLanguageResultExecution timeMemory
234722GoolakhCalvinball championship (CEOI15_teams)C++17
10 / 100
371 ms736 KiB
// 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 (stderr)

teams.cpp:27:45: warning: overflow in implicit constant conversion [-Woverflow]
 const ll maxn=1e4+10, lg=20, mod=1e9+7, inf=1e18;
                                             ^~~~
#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...