답안 #54792

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
54792 2018-07-05T05:45:51 Z 강태규(#1507) Calvinball championship (CEOI15_teams) C++11
100 / 100
729 ms 764 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;
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 - 1], arr[i]);
	}
	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);
         ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 416 KB Output is correct
4 Correct 2 ms 428 KB Output is correct
5 Correct 3 ms 468 KB Output is correct
6 Correct 2 ms 544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 544 KB Output is correct
2 Correct 2 ms 544 KB Output is correct
3 Correct 2 ms 544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 544 KB Output is correct
2 Correct 2 ms 628 KB Output is correct
3 Correct 2 ms 628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 636 KB Output is correct
2 Correct 2 ms 636 KB Output is correct
3 Correct 2 ms 636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 636 KB Output is correct
2 Correct 5 ms 636 KB Output is correct
3 Correct 4 ms 636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 636 KB Output is correct
2 Correct 7 ms 636 KB Output is correct
3 Correct 9 ms 636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 655 ms 732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 113 ms 732 KB Output is correct
2 Correct 105 ms 764 KB Output is correct
3 Correct 168 ms 764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 407 ms 764 KB Output is correct
2 Correct 427 ms 764 KB Output is correct
3 Correct 729 ms 764 KB Output is correct