답안 #810845

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
810845 2023-08-06T16:37:44 Z JakobZorz Calvinball championship (CEOI15_teams) C++14
20 / 100
7 ms 4224 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=1e9+7;
typedef pair<ll,ll>point;
//#define x first
//#define y second

int n;
int arr[10000];

int dp[1000][1000];

int get(int i,int teams){
    if(i==n)
        return 0;
    int res=0;
    teams=max(teams,arr[i]);
    
    for(int team=0;team<arr[i];team++){
        res+=dp[i+1][teams];
        res%=MOD;
    }
    res+=get(i+1,teams);
    res%=MOD;
    
    return res;
}
 
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=0;teams<=n;teams++)
        dp[n][teams]=1;
    
    for(int i=n-1;i>=0;i--){
        for(int teams=0;teams<=i+1;teams++){
            
            dp[i][teams]+=((ll)teams*dp[i+1][teams])%MOD;
            dp[i][teams]%=MOD;
            dp[i][teams]+=dp[i+1][teams+1];
            dp[i][teams]%=MOD;
            
        }
    }
    
    cout<<get(0,0)+1<<"\n";
    
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 724 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4224 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -