답안 #460858

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
460858 2021-08-09T10:33:57 Z kingfran1907 Calvinball championship (CEOI15_teams) C++14
20 / 100
102 ms 65540 KB
#include <bits/stdc++.h>
#define X first
#define Y second

using namespace std;
typedef long long llint;

const int maxn = 1e4+2;
const int base = 31337;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int logo = 18;
const int off = 1 << logo;
const int treesiz = off << 1;

int n;
int niz[maxn];
int dp[maxn][maxn];

int mul(int a, int b) {
	llint out = (llint) a * b;
	return out % mod;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", niz+i);
	}
	
	for (int i = 1; i <= n; i++) dp[0][i] = 1;
	for (int i = 1; i <= n; i++) 
		for (int j = 1; j <= n; j++) 
			dp[i][j] = (dp[i - 1][j + 1] + mul(j, dp[i - 1][j])) % mod;
	
	int sol = 0;
	int maxi = niz[0];
	for (int i = 1; i < n; i++) 
		sol += mul(niz[i] - 1, dp[n - i - 1][maxi]), sol %= mod, maxi = max(maxi, niz[i]); 
	printf("%d\n", sol + 1);
	return 0;
}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
teams.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |   scanf("%d", niz+i);
      |   ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 716 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 3276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 8268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 94 ms 65540 KB Execution killed with signal 9
# 결과 실행 시간 메모리 Grader output
1 Runtime error 87 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 102 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -