답안 #810968

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
810968 2023-08-06T18:43:46 Z JakobZorz Pipes (CEOI15_pipes) C++14
0 / 100
71 ms 724 KB
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <stack>
#include <limits.h>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <cstring>
#include <sstream>
 
#pragma GCC target("popcnt")
 
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD=1e6+7;
typedef pair<ll,ll>point;
//#define x first
//#define y second
 
int n;
int arr[10000];
ll dp[2][1000][2];

int main(){
    ios::sync_with_stdio(false);
    cout.tie(NULL);
    cin.tie(NULL);
    
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        arr[i]--;
    }
    
    
    for(int teams=-1;teams<=n;teams++){
        dp[1][teams+1][0]=1;
        dp[1][teams+1][1]=1;
    }
    
    for(int i=n-1;i>=0;i--){
        for(int teams=-1;teams<=n;teams++){
            {
                ll res=0;
                
                res+=(teams+1)*dp[1][teams+1][0];
                
                res+=dp[1][teams+2][0];
                res%=MOD;
                
                dp[0][teams+1][0]=res;
            }
            
            {
                ll res=0;
                
                res+=min(teams+1,arr[i])*dp[1][teams+1][0];
                if(teams>=arr[i])
                    res+=dp[1][teams+1][1];
                
                if(teams+1<=arr[i])
                    res+=dp[1][teams+2][teams+1==arr[i]];
                res%=MOD;
                
                dp[0][teams+1][1]=res;
            }
        }
        
        memcpy(dp[1],dp[0],1000*2*sizeof(ll));
    }
    
    cout<<dp[0][0][1]<<"\n";
    
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 71 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 51 ms 620 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 724 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 724 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 696 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 724 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 724 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 720 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 712 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -