Submission #546296

# Submission time Handle Problem Language Result Execution time Memory
546296 2022-04-07T05:43:36 Z Soumya1 Calvinball championship (CEOI15_teams) C++17
20 / 100
336 ms 468 KB
#include <bits/stdc++.h>
#ifdef __LOCAL__
#include <debug_local.h>
#endif
using namespace std;
const int mod = 1e9 + 7;
void testCase() {
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) cin >> a[i];
  vector<int> dp(n + 1, 1);
  vector<int> pre(n + 1);
  for (int i = 1; i <= n; i++) pre[i] = max(pre[i - 1], a[i - 1]);
  int ans = 0;
  for (int i = n; i >= 1; i--) {
    vector<int> new_dp(n + 1);
    for (int j = 1; j <= n; j++) {
      new_dp[j] = (1LL * dp[j] * j + dp[j + 1]) % mod;
    }
    for (int j = 1; j < a[i]; j++) {
      ans += dp[max(pre[i], j)];
      if (ans >= mod) ans -= mod;
    }
    dp = new_dp;
  }
  cout << (ans + 1) % mod << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  testCase();
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 320 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 336 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 62 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 241 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -