답안 #54773

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
54773 2018-07-05T04:50:30 Z 1등은 나의 것^^(#2059) Calvinball championship (CEOI15_teams) C++11
100 / 100
400 ms 1248 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 10005, mod = 1e6+7;

ll n, a[N], mx[N], dt[2][N];

int main()
{
	scanf("%lld",&n);
	for(ll i=1;i<=n;i++) {
		scanf("%lld",&a[i]);
		mx[i] = max(mx[i-1], a[i]);
		dt[n%2][i] = 1;
	}
	ll ans = a[n];
	for(ll i=n-1;i>=1;i--) {
		for(ll j=1;j<=i;j++) {
			dt[i%2][j] = (dt[1-i%2][j] * j + dt[1-i%2][j+1]) % mod;
		}
		for(ll j=1;j<a[i];j++) {
			ans = (ans + dt[i%2][max(mx[i-1], j)]) % mod;
		}
	}
	printf("%lld\n",ans);
}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&n);
  ~~~~~^~~~~~~~~~~
teams.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&a[i]);
   ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 3 ms 492 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 3 ms 532 KB Output is correct
5 Correct 2 ms 532 KB Output is correct
6 Correct 2 ms 532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 572 KB Output is correct
2 Correct 2 ms 700 KB Output is correct
3 Correct 2 ms 700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 700 KB Output is correct
2 Correct 2 ms 700 KB Output is correct
3 Correct 2 ms 700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 700 KB Output is correct
2 Correct 3 ms 700 KB Output is correct
3 Correct 2 ms 700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 700 KB Output is correct
2 Correct 3 ms 700 KB Output is correct
3 Correct 3 ms 700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 724 KB Output is correct
2 Correct 5 ms 724 KB Output is correct
3 Correct 6 ms 728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 373 ms 1148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 1148 KB Output is correct
2 Correct 30 ms 1148 KB Output is correct
3 Correct 101 ms 1148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 121 ms 1204 KB Output is correct
2 Correct 120 ms 1204 KB Output is correct
3 Correct 400 ms 1248 KB Output is correct