Submission #405454

# Submission time Handle Problem Language Result Execution time Memory
405454 2021-05-16T12:10:56 Z MeGustaElArroz23 Calvinball championship (CEOI15_teams) C++14
70 / 100
39 ms 65540 KB
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
 
const ll mod=1000007;
 
int main(){
    
    ll n;
    cin >> n;
    
    vector<vector<int>> sol(n+1,vector<int>(n+1,1));  //sol[n][x]
    for (ll i=1;i<=n;i++) sol[1][i]=i+1;
    for (ll i=2;i<=n;i++){
        for (ll j=1;j<=n-i+1;j++) sol[i][j]=(j*sol[i-1][j]+sol[i-1][j+1])%mod;
    }
    
    vi v(n);
    for (ll i=n-1;i>=0;i--) cin >> v[i];
    ll res=0;
    int maxvisto=0;
    for (ll i=n-1;i>=0;i--){
        res+=(v[i]-1)*sol[i][maxvisto]%mod;
        maxvisto=max(v[i],maxvisto);
        //cerr << i << ' ' << v[i] <<' '<< res << '\n';
    }
    cout <<(res+1)%mod<<'\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1228 KB Output is correct
2 Correct 2 ms 1228 KB Output is correct
3 Correct 2 ms 1228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4172 KB Output is correct
2 Correct 4 ms 4172 KB Output is correct
3 Correct 4 ms 4172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 38 ms 65540 KB Execution killed with signal 9
# Verdict Execution time Memory Grader output
1 Runtime error 36 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 39 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -