Submission #405403

# Submission time Handle Problem Language Result Execution time Memory
405403 2021-05-16T10:52:17 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<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;

const ll mod=1000007;

ll power(int a, int b){
    if (b==0) return 1;
    ll sol=power(a,b/2)%mod;
    sol=sol*sol%mod;
    if (b%2) sol*=a;
    cerr << a <<' '<<b<<' '<<sol<<'\n';
    return sol%mod;
}

int main(){
    
    ll n;
    cin >> n;
    
    vvi sol(n+1,vi(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;
    ll 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 3 ms 2272 KB Output is correct
2 Correct 3 ms 2196 KB Output is correct
3 Correct 2 ms 2252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 8140 KB Output is correct
2 Correct 8 ms 8140 KB Output is correct
3 Correct 7 ms 8140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 39 ms 65540 KB Execution killed with signal 9
# Verdict Execution time Memory Grader output
1 Runtime error 33 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 36 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -