Submission #89386

# Submission time Handle Problem Language Result Execution time Memory
89386 2018-12-13T00:28:36 Z sjhuang26 Calvinball championship (CEOI15_teams) C++14
30 / 100
110 ms 848 KB
#include<iostream>
using namespace std;
int a[10000],N,x[10000];
typedef long long ll;
ll d[2][10001];//given at nth position (implicit, reverse) and cutoff index (starts at 0): # of possibilities?
const int md=1e6+7,ans=0;
int main(){
  cin>>N;
  for(int i=0;i<N;++i)cin>>a[i];
  int u=0,ans=0;
  for(int i=0;i<N;++i){
    x[i]=u=max(u,a[i]);
  }
  for(int i=0;i<=N;++i){
    d[N%2][i]=1;
  }
  for(int i=N-1;i>=0;--i){
    for(int j=0;j<=i;++j){
      d[i%2][j]=(d[(i+1)%2][j+1]+d[(i+1)%2][j]*j)%md;
    }
    if(i==N-1){
      ans+=(d[i%2][a[i]-1]);
    }else{
      ans+=(d[(i+1)%2][x[i]-1]*(a[i]-1));
    }
    ans%=md;
    //cout<<ans<<endl;
  }
  cout<<ans<<'\n';
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 372 KB Output is correct
3 Correct 2 ms 448 KB Output is correct
4 Correct 2 ms 448 KB Output is correct
5 Correct 2 ms 596 KB Output is correct
6 Correct 2 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 596 KB Output is correct
2 Correct 2 ms 596 KB Output is correct
3 Correct 2 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 110 ms 848 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 848 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 110 ms 848 KB Output isn't correct
2 Halted 0 ms 0 KB -