답안 #476127

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
476127 2021-09-24T21:15:59 Z elgamalsalman Calvinball championship (CEOI15_teams) C++14
100 / 100
724 ms 660 KB
#include <bits/stdc++.h>

using namespace std;

#define MODVAL 1000007

typedef long long ll;
typedef vector<int> vi;

int n, m[10010];
ll dp[200020];
vi a;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin >> n;
  a = {1};
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  n++;
  reverse(a.begin(), a.end());

  int mx = 1;
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] > mx) mx = a[i];
    m[i] = mx;
  }

  fill(dp, dp + 2 * n + 10, 1);
  ll ans = 1;
  for (int i = 0; i < n - 1; i++) {
    if (i) for (int j = 0; j < 2 * n + 5; j++) {
      dp[j] *= j;
      dp[j] %= MODVAL;
      dp[j] += dp[j + 1];
      dp[j] %= MODVAL;
    }
    ans += ((a[i] - 1) * dp[m[i + 1]]) % MODVAL;
    ans %= MODVAL;
  }
  cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 292 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 328 KB Output is correct
2 Correct 8 ms 332 KB Output is correct
3 Correct 8 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 699 ms 648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 174 ms 460 KB Output is correct
2 Correct 178 ms 460 KB Output is correct
3 Correct 182 ms 476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 716 ms 640 KB Output is correct
2 Correct 716 ms 636 KB Output is correct
3 Correct 724 ms 660 KB Output is correct