# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
707814 | 2023-03-10T08:38:09 Z | Alihan_8 | 구경하기 (JOI13_watching) | C++17 | 1000 ms | 31388 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 = 2e3+1; int dp[N][N]; bool chmin(int &x, int y){ bool flag = false; if ( x > y ){ x = y; flag |= true; } return flag; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n, P, Q; cin >> n >> P >> Q; chmin(P, n), chmin(Q, n); vector <int> p(n); for ( auto &i: p ) cin >> i; sort(all(p)); p.resize(unique(all(p))-p.begin()); n = (int)p.size(); const int inf = 1e16+1; auto ok = [&](int w){ for ( int i = 0; i <= n; i++ ){ for ( int j = 0; j <= P; j++ ){ dp[i][j] = inf; } } for ( int i = 0; i <= P; i++ ) dp[0][i] = 0; auto f = [&](int x){ return lower_bound(all(p), x)-p.begin(); }; for ( int i = 1; i <= n; i++ ){ for ( int j = 0; j <= P; j++ ){ int val = f(p[i-1]-w*2+1); chmin(dp[i][j], dp[val][j]+1); if ( j ){ val = f(p[i-1]-w+1); chmin(dp[i][j], dp[val][j-1]); } } } return dp[n][P] <= Q; }; int l = 1, r = 1e9; while ( l < r ){ int md = (l+r) >> 1; if ( ok(md) ) r = md; else l = md+1; } cout << l; cout << '\n'; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 724 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 7 ms | 724 KB | Output is correct |
5 | Correct | 1 ms | 724 KB | Output is correct |
6 | Correct | 6 ms | 724 KB | Output is correct |
7 | Correct | 1 ms | 724 KB | Output is correct |
8 | Correct | 1 ms | 724 KB | Output is correct |
9 | Correct | 1 ms | 724 KB | Output is correct |
10 | Correct | 1 ms | 712 KB | Output is correct |
11 | Correct | 4 ms | 712 KB | Output is correct |
12 | Correct | 3 ms | 724 KB | Output is correct |
13 | Correct | 1 ms | 724 KB | Output is correct |
14 | Correct | 1 ms | 712 KB | Output is correct |
15 | Correct | 1 ms | 716 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 8532 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Execution timed out | 1069 ms | 31388 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |