답안 #35983

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
35983 2017-12-04T04:36:45 Z funcsr Calvinball championship (CEOI15_teams) C++14
100 / 100
716 ms 2132 KB
#include <iostream>
#include <fstream>
#include <bitset>
#include <cassert>
#include <vector>
#define rep(i, n) for (int i=0; i<(n); i++)
#define INF 1145141919
#define MOD 1000007
#define pb push_back
using namespace std;
inline void add(int &x, int v) { x += v; if (x >= MOD) x -= MOD; }

int N;
int A[10000];
int dp[2][10000];

signed main() {
  cin >> N;
  rep(i, N) cin >> A[i], A[i]--;
  int lm = 0;
  for (int i=1; i<N; i++) {
    rep(s, i+1) dp[1][s] = 0;
    rep(s, i+1) {
      add(dp[1][s], (1LL*(s+1)*dp[0][s])%MOD);
      add(dp[1][s+1], dp[0][s]);
    }
    add(dp[1][lm], A[i]);

    if (A[i] == lm+1) lm++;
    swap(dp[0], dp[1]);
  }
  int s = 0;
  rep(i, N) add(s, dp[0][i]);
  cout << s+1 << "\n";
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2132 KB Output is correct
2 Correct 0 ms 2132 KB Output is correct
3 Correct 0 ms 2132 KB Output is correct
4 Correct 0 ms 2132 KB Output is correct
5 Correct 0 ms 2132 KB Output is correct
6 Correct 0 ms 2132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2132 KB Output is correct
2 Correct 0 ms 2132 KB Output is correct
3 Correct 0 ms 2132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2132 KB Output is correct
2 Correct 0 ms 2132 KB Output is correct
3 Correct 0 ms 2132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2132 KB Output is correct
2 Correct 0 ms 2132 KB Output is correct
3 Correct 0 ms 2132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2132 KB Output is correct
2 Correct 6 ms 2132 KB Output is correct
3 Correct 6 ms 2132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 2132 KB Output is correct
2 Correct 13 ms 2132 KB Output is correct
3 Correct 13 ms 2132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 646 ms 2132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 219 ms 2132 KB Output is correct
2 Correct 206 ms 2132 KB Output is correct
3 Correct 199 ms 2132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 716 ms 2132 KB Output is correct
2 Correct 713 ms 2132 KB Output is correct
3 Correct 683 ms 2132 KB Output is correct