# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
336727 | lovro_nidogon1 | Cover (COCI18_cover) | C++14 | 5 ms | 492 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define breturn return
using namespace std;
vector<pair<int, int> > kor, hull, bruh;
pair<int, int> poc;
int n, a, b, c, dp[5002];
bool ccw(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
// cout << a.first << " " << a.second << " - " << b.first << " " << b.second << " - " << c.first << " " << c.second << '\n';
if(a.first * (b.second - c.second) + b.first * (c.second - a.second) + c.first * (a.second - b.second) < 0) breturn true;
else breturn false;
}
int main() {
cin >> n;
c = -1;
for(int i = 0; i < n; i++) {
cin >> a >>b;
a = abs(a), b = abs(b);
kor.push_back({a, b});
if(b > c) c = b, poc = {a, b};
}
if(n == 1) breturn cout << a * b << '\n', 0;
sort(kor.begin(), kor.end());
int x = 0;
while(kor[x] != poc) x++;
hull.push_back(kor[x]);
for(int i = x; i < n; i++) {
if(kor[i].first > hull[hull.size() - 1].first and kor[i].second < hull[hull.size() - 1].second) hull.push_back(kor[i]);
}
dp[0] = 0;
for(int i = 0; i < hull.size(); i++) {
bruh.push_back({hull[i].second, dp[i]});
int l = 0;
int r = bruh.size() - 1;
while(l != r) {
int mid = (l + r)/2;
if(bruh[mid].first * hull[i].first + bruh[mid].second > bruh[mid + 1].first * hull[i].first + bruh[mid + 1].second) l = mid + 1;
else r = mid;
}
dp[i + 1] = bruh[l].first * hull[i].first + bruh[l].second;
}
cout << dp[hull.size()] * 4;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |