Submission #55196

# Submission time Handle Problem Language Result Execution time Memory
55196 2018-07-06T09:51:03 Z istlemin Calvinball championship (CEOI15_teams) C++14
70 / 100
664 ms 66560 KB
#include<bits/stdc++.h>

using namespace std;

#define rep(i,a,b) for(int i = a; i<int(b);++i)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define trav(a,c) for(auto a: c)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;

int main(){
	cin.sync_with_stdio(false);
    ll n;
    cin>>n;
    vi v(n);
    rep(i,0,n) cin>>v[i];

    vector<vector<int> > dp(n+1,vector<int>(n+1,1));

    ll mod = 1e6+7;

    rep(left,1,n+1)
		rep(numTeams,1,n-left+1)
			dp[left][numTeams] = (numTeams*dp[left-1][numTeams] + dp[left-1][numTeams+1])%mod;

    ll numTeams = 1;
    ll ans = 0;
    rep(i,0,n){
		ans = (ans + (v[i]-1)*dp[n-i-1][numTeams])%mod;
        numTeams = max(v[i],numTeams);
    }

    cout<<(ans+1)%mod<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 428 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 2 ms 536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 664 KB Output is correct
2 Correct 2 ms 664 KB Output is correct
3 Correct 2 ms 664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 664 KB Output is correct
2 Correct 2 ms 664 KB Output is correct
3 Correct 3 ms 664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 664 KB Output is correct
2 Correct 2 ms 664 KB Output is correct
3 Correct 3 ms 664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1516 KB Output is correct
2 Correct 3 ms 1516 KB Output is correct
3 Correct 4 ms 1516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4588 KB Output is correct
2 Correct 8 ms 4588 KB Output is correct
3 Correct 9 ms 4588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 664 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 465 ms 66560 KB Memory limit exceeded 66560 {'time-wall': '1.804', 'max-rss': '67444', 'csw-forced': '248', 'cg-mem': '66560', 'time': '0.465', 'csw-voluntary': '5940'} 65536
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 646 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -