Submission #569951

# Submission time Handle Problem Language Result Execution time Memory
569951 2022-05-28T10:36:56 Z 600Mihnea Calvinball championship (CEOI15_teams) C++17
70 / 100
185 ms 420 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 10000 + 7;
const int M = 1000007;

int n, a[N], mx[N], ways[N];

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);


  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    mx[i] = max(mx[i - 1], a[i]);
    ways[i] = 1;
  }

  int sol = 1;
  for (int i = n; i >= 1; i--) {
    sol = (sol + (a[i] - 1) * (ways[mx[i - 1]])) % M;
    for (int j = 1; j <= n; j++) {
      ways[j] = (j * ways[j] + ways[j + 1]) % M;
    }
  }
  cout << sol << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 1 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# 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 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 146 ms 420 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 185 ms 416 KB Output isn't correct
2 Halted 0 ms 0 KB -