Submission #54791

# Submission time Handle Problem Language Result Execution time Memory
54791 2018-07-05T05:42:07 Z 강태규(#1507) Calvinball championship (CEOI15_teams) C++11
30 / 100
667 ms 720 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

const int mod = 1000007;
int dp[10002];

int n, m;
int arr[10001];
int mx[10001];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
        scanf("%d", arr + i);
        mx[i] = max(mx[i], arr[i]);
	}
	m = mx[n];
	for (int i = 1; i <= n; ++i) {
        dp[i] = 1;
	}
	int ans = 1;
	for (int i = n; i > 0; --i) {
        for (int j = 1; j < arr[i]; ++j) {
            ans += dp[max(mx[i - 1], j)];
            ans %= mod;
        }
        for (int j = 1; j <= n; ++j) {
            dp[j] = (llong)dp[j] * j % mod + dp[j + 1];
            dp[j] %= mod;
        }
	}
	printf("%d\n", ans);
	return 0;
}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
teams.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", arr + i);
         ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 356 KB Output is correct
4 Correct 2 ms 432 KB Output is correct
5 Correct 2 ms 432 KB Output is correct
6 Correct 2 ms 432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 432 KB Output is correct
2 Incorrect 2 ms 432 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 508 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 556 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 556 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 667 ms 688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 135 ms 688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 474 ms 720 KB Output isn't correct
2 Halted 0 ms 0 KB -