| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 210834 | Nucleist | Watching (JOI13_watching) | C++14 | 932 ms | 71524 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
struct greateri
{
template<class T>
bool operator()(T const &a, T const &b) const { return a > b; }
};
ll n,p,q,w;
set<ll> hed;
ve hedi;
map<ll,ll>pos;
ll dp[3001][3001];
ll next1[3001][2];
ll solve(ll index,ll rem)
{
if(index==(hed.size()-1))return 0;
if(dp[index][rem]!=-1)return dp[index][rem];
ll ans=pow(10,16);
if(rem>0)
{
ans=min(ans,solve(next1[index][1],rem-1));
}
{
ans=min(ans,1+solve(next1[index][0],rem));
}
return dp[index][rem]=ans;
}
int main()
{
//flash;
cin>>n>>p>>q;
memset(dp,-1,sizeof dp);
for (ll i = 0; i < n; ++i)
{
ll xo;
cin>>xo;
hed.insert(xo);
}
hed.insert(30000000000);
ll ans=-1;
for(auto it:hed){hedi.pb(it);pos[it]=hedi.size()-1;}
ll low=1;
ll high=INF;
while(low<=high)
{
ll med=(low+high)/2;
w=med;
for (int i = 0; i < n; ++i)
{
auto u=hed.lower_bound(hedi[i]+w);
auto k=pos[(*u)];
next1[i][0]=k;
u=hed.lower_bound(hedi[i]+2*w);
k=pos[(*u)];
next1[i][1]=k;
}
memset(dp,-1,sizeof dp);
ll k = solve(0,min(q,n));
if(k<=p)
{
ans=med;
high=med-1;
}
else
{
low=med+1;
}
}
cout<<ans;
return 0;
}
//code the AC sol !
// BS/queue/map컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
