답안 #1001935

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1001935 2024-06-19T08:37:26 Z vjudge1 구경하기 (JOI13_watching) C++17
50 / 100
1000 ms 3788 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 1000000000
int n, p, q;
vector<int> a;
int main(){
    cin>>n>>p>>q;
    a.assign(n + 1, 0);
    for (int i = 1; i <= n; i++){
        cin>>a[i];
    }
    sort(a.begin(), a.end());
    if (n <= p + q){
        cout<<1;
        return 0;
    }
    ll dp[n + 1][p + 1][q + 1];
    for (int i = 0; i <= n; i++){
        for (int j = 0; j <= p; j++){
            for (int k = 0; k <= q; k++){
                dp[i][j][k] = 0;
            }
        }
    }
    for (int i = 1; i <= n; i++){
        for (int j = 0; j <= p; j++){
            for (int k = 0; k <= q; k++){
                if (j + k >= i){
                    dp[i][j][k] = 1;
                    continue;
                }
                dp[i][j][k] = INF;
                for (int l = 0; l < i; l++){
                    ll dist = a[i] - a[l + 1] + 1;
                    ll bi = ceil((double)dist / (double)2);
                    if (j != 0){
                        dp[i][j][k] = min(max(dp[l][j - 1][k], dist), dp[i][j][k]);
                    }
                    if (k != 0){
                        dp[i][j][k] = min(max(dp[l][j][k - 1], bi), dp[i][j][k]);
                    }
                }
            }
        }
    }
    cout<<dp[n][p][q];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 508 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 4 ms 348 KB Output is correct
9 Correct 4 ms 436 KB Output is correct
10 Correct 41 ms 1116 KB Output is correct
11 Correct 41 ms 1116 KB Output is correct
12 Correct 93 ms 2396 KB Output is correct
13 Correct 2 ms 432 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 3 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 496 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 444 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 508 KB Output is correct
7 Execution timed out 1098 ms 3788 KB Time limit exceeded
8 Halted 0 ms 0 KB -