답안 #62527

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
62527 2018-07-28T23:59:00 Z MatheusLealV Calvinball championship (CEOI15_teams) C++17
0 / 100
707 ms 66560 KB
#include <bits/stdc++.h>
#define N 10001
using namespace std;
typedef long long ll;

int n, k, v[N], tot, used[N], mod = 1000007;

int dp[N][N];

int solve(int i, int k)
{
	if(i > n) return 1;

	if(dp[i][k] != -1) return dp[i][k];

	ll A = (((ll)solve(i + 1, k) * (ll)k) % mod + solve(i + 1, k + 1) % mod)%mod;

	return dp[i][k] = A;
}

inline ll pos()
{
	set<ll> add;

	ll q;

	memset(dp, -1, sizeof dp);

	for(ll i = 1; i <= n; i++)
	{
		tot = (tot + (ll)solve(i + 1, add.size())*((ll)v[i] - 1LL) )%mod;

		add.insert(v[i]);
	}

	return (tot + 1)%mod;
}

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

	cin>>n;

	for(int i = 1; i <= n; i++) cin>>v[i];

	cout<<pos()<<"\n";
}

Compilation message

teams.cpp: In function 'll pos()':
teams.cpp:25:5: warning: unused variable 'q' [-Wunused-variable]
  ll q;
     ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 575 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 707 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 569 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 650 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 638 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 663 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 614 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 631 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 613 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 662 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -