답안 #707634

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
707634 2023-03-09T15:27:58 Z Alihan_8 구경하기 (JOI13_watching) C++17
50 / 100
55 ms 16848 KB
#include <bits/stdc++.h>
// include <ext/pb_ds/assoc_container.hpp>
// include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define all(x) x.begin(), x.end()
#define pb push_back
// define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define mpr make_pair
#define ln '\n'
void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
#define int long long
const int N = 1e2+1;
int dp[N][N][N];
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, P, Q; cin >> n >> P >> Q;
    vector <int> p(n);
    for ( auto &i: p ) cin >> i;
    P = min(P, n), Q = min(Q, n);
    sort(all(p));
    p.erase(unique(all(p)), p.end());
    n = (int)p.size();
    auto ok = [&](int w){
        memset(dp, 0, sizeof(dp));
        auto get = [&](int x){
            return lower_bound(all(p), x)-p.begin();
        };
        for ( int i = 0; i <= P; i++ ){
            for ( int j = 0; j <= Q; j++ ) dp[0][i][j] = true;
        }
        for ( int i = 1; i <= n; i++ ){
            int L = get(p[i-1]-w+1), R = get(p[i-1]-2*w+1);
            for ( int j = 0; j <= P; j++ ){
                for ( int k = 0; k <= Q; k++ ){
                    if ( j ) dp[i][j][k] |= dp[L][j-1][k];
                    if ( k ) dp[i][j][k] |= dp[R][j][k-1];
                }
            }
        }
        return dp[n][P][Q];
    };
    int l = 1, r = 1e9+1;
    while ( l < r ){
        int md = (l+r) >> 1;
        if ( ok(md) ) r = md;
        else l = md+1;
    }
    cout << l;

    cout << '\n';
}

Compilation message

watching.cpp: In function 'void IO(std::string)':
watching.cpp:11:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 | void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
watching.cpp:11:70: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 | void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                                                               ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 8276 KB Output is correct
2 Correct 18 ms 8272 KB Output is correct
3 Correct 18 ms 8388 KB Output is correct
4 Correct 30 ms 8384 KB Output is correct
5 Correct 22 ms 8264 KB Output is correct
6 Correct 55 ms 8372 KB Output is correct
7 Correct 19 ms 8276 KB Output is correct
8 Correct 23 ms 8276 KB Output is correct
9 Correct 18 ms 8276 KB Output is correct
10 Correct 23 ms 8388 KB Output is correct
11 Correct 23 ms 8276 KB Output is correct
12 Correct 27 ms 8276 KB Output is correct
13 Correct 18 ms 8352 KB Output is correct
14 Correct 19 ms 8392 KB Output is correct
15 Correct 19 ms 8384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 12 ms 16848 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -