| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1001851 | vjudge1 | 구경하기 (JOI13_watching) | C++17 | 15 ms | 604 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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.resize(n + 1);
for (int i = 1; i <= n; i++){
cin>>a[i];
}
set<vector<int>> s;
for (int i = 1; i <= n; i++){
s.insert({a[i], a[i], 1});
}
vector<int> fi, se;
while (s.size() > p + q){
fi = {0, 0, 1}, se = {1000000000, 1000000000, 1};
auto it = s.begin();
while(it != s.end()){
auto ne = next(it);
if (ne != s.end()){
if (ne->at(2) + it->at(2) + ne->at(0) - it->at(1) < se[0] - fi[1] + fi[2] + se[2]){
fi = *it;
se = *ne;
}
}
it = ne;
}
vector<int> fu = {fi[0], se[1], se[1] - fi[0] + 1};
s.erase(fi);
s.erase(se);
s.insert(fu);
}
vector<int> fin;
for (auto el : s){
fin.push_back(el[1] - el[0] + 1);
}
sort(fin.begin(), fin.end());
reverse(fin.begin(), fin.end());
int ans = 0;
for (int i = 0; i < p + q; i++){
if (i < q){
ans = max(ans, int(ceil(double(fin[i]) / (double)2)));
}
else{
ans = max(ans, fin[i]);
}
}
cout<<ans;
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
