# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
73199 | test | 오르막길 (FXCUP3_hill) | C++14 | 1566 ms | 35960 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MN = 300010;
ll cross(pii a, pii b) {
return 1LL * a.first * b.second - 1LL * a.second * b.first;
}
ll ccw(pii a, pii b, pii c) {
pii p = pii(b.first - a.first, b.second - a.second);
pii q = pii(c.first - a.first, c.second - a.second);
return cross(p, q);
}
int gcd(int a, int b) {
return b? gcd(b, a % b) : a;
}
int N;
ll C;
pii P[MN];
struct frac {
int a, b;
pii p;
bool operator <(const frac &i) const {
return 1LL * b * i.a < 1LL * a * i.b || (1LL * b * i.a == 1LL * a * i.b && p < i.p);
}
};
set<frac> st;
set<pii> pp;
int main() {
scanf("%d %lld", &N, &C);
C *= 2;
for(int i = 0; i < N; i++) {
scanf("%d", &P[i].first);
}
for(int i = 0; i < N; i++) {
scanf("%d", &P[i].second);
}
for(int i = 0; i < N - 1; i++) {
st.insert({ P[i + 1].first - P[i].first, P[i + 1].second - P[i].second, P[i] });
}
for(int i = 0; i < N; i++) {
pp.insert(P[i]);
}
while(1) {
frac t = *st.rbegin();
pii cur = t.p;
pp.erase(cur);
set<pii>::iterator it = pp.lower_bound(cur);
if(it == pp.begin()) break;
pii nxt = *it;
pii pre = *(--it);
ll need = abs(ccw(pre, cur, nxt));
if(need > C) break;
C -= need;
st.erase(t);
st.erase({ cur.first - pre.first, cur.second - pre.second, pre });
st.insert({ nxt.first - pre.first, nxt.second - pre.second, pre });
}
frac t = *st.rbegin();
int A = t.a;
int B = t.b;
int G = gcd(A, B);
A /= G;
B /= G;
printf("%d/%d", B, A);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |