# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
26240 | 2017-06-28T13:16:14 Z | Kerim | Calvinball championship (CEOI15_teams) | C++14 | 486 ms | 2596 KB |
#include "bits/stdc++.h" #define MAXN 10009 #define INF 1000007 #define mp(x,y) make_pair(x,y) #define all(v) v.begin(),v.end() #define pb(x) push_back(x) #define wr cout<<"----------------"<<endl; #define ppb() pop_back() #define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++) #define ff first #define ss second #define my_little_dodge 46 #define debug(x) cerr<< #x <<" = "<< x<<endl; using namespace std; typedef long long ll; typedef pair<int,int> PII; template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;} template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;} int dp[2][MAXN],n; vector<PII>add[MAXN]; int mod(ll x){ return (x%INF); } int main(){ //~ #ifndef ONLINE_JUDGE //~ freopen("file.in", "r", stdin); //~ #endif scanf("%d",&n);int cnt=0,ans=1; for(int i=1;i<=n;i++){ int x; scanf("%d",&x); add[i+1].pb(mp(cnt,min(x-1,cnt))); if(cnt+1<x) add[i+1].pb(mp(cnt+1,1)); if(cnt+1==x) cnt++; } for(int i=0;i<=n;i++) dp[(n+1)&1][i]=1; tr(it,add[n+1]) ans=mod(ans+mod(dp[(n+1)&1][it->ff]*1LL*it->ss)); for(int i=n;i>1;i--){ for(int j=0;j<=n;j++){ dp[i&1][j]=dp[(i&1)^1][j+1]; dp[i&1][j]=mod(dp[i&1][j]+mod(dp[(i&1)^1][j]*1LL*j)); } tr(it,add[i]) ans=mod(ans+mod(dp[i&1][it->ff]*1LL*it->ss)); } printf("%d\n",ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2332 KB | Output is correct |
2 | Correct | 0 ms | 2332 KB | Output is correct |
3 | Correct | 0 ms | 2332 KB | Output is correct |
4 | Correct | 0 ms | 2332 KB | Output is correct |
5 | Correct | 0 ms | 2332 KB | Output is correct |
6 | Correct | 0 ms | 2332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2332 KB | Output is correct |
2 | Correct | 0 ms | 2332 KB | Output is correct |
3 | Correct | 0 ms | 2332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2332 KB | Output is correct |
2 | Correct | 0 ms | 2332 KB | Output is correct |
3 | Correct | 0 ms | 2332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2332 KB | Output is correct |
2 | Correct | 0 ms | 2332 KB | Output is correct |
3 | Correct | 0 ms | 2332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2332 KB | Output is correct |
2 | Correct | 0 ms | 2332 KB | Output is correct |
3 | Correct | 0 ms | 2332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2332 KB | Output is correct |
2 | Correct | 6 ms | 2332 KB | Output is correct |
3 | Correct | 3 ms | 2332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 473 ms | 2596 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 109 ms | 2464 KB | Output is correct |
2 | Correct | 116 ms | 2464 KB | Output is correct |
3 | Correct | 113 ms | 2464 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 469 ms | 2596 KB | Output is correct |
2 | Correct | 486 ms | 2596 KB | Output is correct |
3 | Correct | 479 ms | 2596 KB | Output is correct |