답안 #131087

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
131087 2019-07-16T12:51:11 Z arthurconmy Calvinball championship (CEOI15_teams) C++14
70 / 100
76 ms 65540 KB
/* Arthur Conmy / arthurconmy */
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <random>
#include <stack>
#include <deque>
#include <chrono>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef pair<int,int> pii;
#define REP(i, a, b) for (ll i = ll(a); i <= ll(b); i++)
#define REPb(j, d, c) for (ll j = ll(d); j >= ll(c); j--)
#define ff first
#define ss second
#define pb push_back
#define len(x) int((x).size())
#define endl "\n"

const ll MAXN=10001;
const ll p=1000007;
ll A[MAXN];
ll sz[MAXN][MAXN];
ll pos[MAXN][MAXN];

int main() // LL OR INT??
{
	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll n;
	cin>>n;

	if(n==1)
	{
		cout << 1 << endl;
		return 0;
	}

	ll thing_max=1;

	REP(i,1,n)
	{
		ll a;
		cin>>a;
		A[i]=a;
		thing_max=max(thing_max,a);
	}

	sz[1][1]=ll(1);
	pos[1][1]=ll(1);

	bool just_ones=1;
	ll cur_max=1;

	REP(i,2,n)
	{
		sz[i][1]=1;
		if(just_ones&&A[i]==1) pos[i][1]=0;
		else
		{
			just_ones=0;
			pos[i][1]=1;
		}

		// int j=1;
		// cout << i << " " << j << " " << pos[i][j] << endl;

		REP(j,2,i-1)
		{
			sz[i][j]=sz[i-1][j-1]+j*sz[i-1][j];
			sz[i][j]%=p;

			pos[i][j]=pos[i-1][j-1]
					 +j*pos[i-1][j]
					 +ll(j==cur_max)*(A[i]-1);

			pos[i][j]%=p;
		
			// cout << i << " " << j << " " << pos[i][j] << endl;
		}

		// cout << i << " " << i << " " << pos[i][i] << endl; 
	
		cur_max=max(cur_max,A[i]);
	}

	ll ans=0;

	REP(j,1,n)
	{
		ans+=pos[n][j];
		ans%=p;
	}

	ans++;
	ans%=p;

	cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1272 KB Output is correct
2 Correct 3 ms 1272 KB Output is correct
3 Correct 3 ms 1272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 6492 KB Output is correct
2 Correct 9 ms 6492 KB Output is correct
3 Correct 7 ms 6392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 16404 KB Output is correct
2 Correct 16 ms 16376 KB Output is correct
3 Correct 18 ms 16464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 76 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 70 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 76 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -