답안 #243842

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
243842 2020-07-02T02:15:45 Z errorgorn Calvinball championship (CEOI15_teams) C++14
100 / 100
194 ms 768 KB
//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int MOD=1000007;

int n;
int arr[10005];
int mx[10005];
ll memo[2][10005];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	memset(memo,-1,sizeof(memo));
	
	cin>>n;
	rep(x,0,n) cin>>arr[x];
	rep(x,1,n) mx[x]=max(mx[x-1],arr[x-1]);
	
	int a=0,b=1;
	rep(x,0,10005) memo[a][x]=1;
	
	ll ans=1;
	rep(x,n,0){
		ans=(ans+memo[a][mx[x]]*(arr[x]-1))%MOD;
		
		rep(x,0,10004) memo[b][x]=(memo[a][x+1]+memo[a][x]*x)%MOD;
		swap(a,b);
	}
	
	cout<<ans<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 4 ms 512 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 512 KB Output is correct
2 Correct 9 ms 512 KB Output is correct
3 Correct 6 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 512 KB Output is correct
2 Correct 14 ms 512 KB Output is correct
3 Correct 19 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 512 KB Output is correct
2 Correct 23 ms 512 KB Output is correct
3 Correct 23 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 190 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 101 ms 512 KB Output is correct
2 Correct 103 ms 600 KB Output is correct
3 Correct 101 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 192 ms 640 KB Output is correct
2 Correct 194 ms 640 KB Output is correct
3 Correct 194 ms 768 KB Output is correct