답안 #810956

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
810956 2023-08-06T18:10:53 Z JakobZorz Calvinball championship (CEOI15_teams) C++14
60 / 100
1000 ms 8072 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[1000][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 i=n;i>=0;i--){
        for(int teams=-1;teams<=n;teams++){
            for(int equal=0;equal<=1;equal++){
                
                if(i==n){
                    dp[i][teams+1][equal]=1;
                    continue;
                }
                
                ll res=0;
                
                for(int new_team=0;new_team<=teams;new_team++){
                    if(new_team<=arr[i]||!equal){
                        res+=dp[i+1][teams+1][equal&&new_team==arr[i]];
                        res%=MOD;
                    }
                }
                if(teams+1<=arr[i]||!equal){
                    res+=dp[i+1][teams+2][equal&&teams+1==arr[i]];
                    res%=MOD;
                }
                
                dp[i][teams+1][equal]=res;
            }
        }
    }
    
    cout<<dp[0][0][true]<<"\n";
    
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 212 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 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 Correct 4 ms 852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 852 KB Output is correct
2 Correct 3 ms 852 KB Output is correct
3 Correct 4 ms 852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 294 ms 6164 KB Output is correct
2 Correct 297 ms 6232 KB Output is correct
3 Correct 404 ms 6252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1075 ms 8072 KB Time limit exceeded
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 -