QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#660994 | #9427. Collect the Coins | NobodyThere | WA | 0ms | 3752kb | C++17 | 1.4kb | 2024-10-20 14:13:52 | 2024-10-20 14:13:53 |
Judging History
answer
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
typedef long long ll;
constexpr int N = 1e6;
template <typename T> inline void read(T &x) {
char ch; x = 0;
while((ch = getchar()) <= 32);
do {x = x * 10 + (ch & 15);} while((ch = getchar()) > 32);
}
template <typename T, typename ... _T>
inline void read(T &x, _T &...y) {read(x), read(y...);}
template <typename T> inline T abs(const T &x) {
return x < 0 ? -x : x;
}
int n;
struct note {
ll t, x;
} a[N + 3];
bool chk(ll v) {
note lst;
int vis = 0;
for(int i = 2; i <= n; i++) {
if(v * (a[i].t - a[i - 1].t) < abs(a[i].x - a[i - 1].x)) {
if(!vis) {
vis = 1;
} else if(v * (a[i].t - lst.t) < abs(a[i].x - lst.x)) {
return 0;
}
lst = a[i - 1];
}
}
return 1;
}
int T;
int main() {
// freopen("B.in", "r", stdin);
// freopen("B.out", "w", stdout);
read(T);
while(T--){
read(n);
for(int i = 1; i <= n; i++) {
read(a[i].t, a[i].x);
}
std::sort(a + 1, a + n + 1, [](note x, note y) {
return x.t < y.t;
});
ll L = 0, R = 1'000'000'000;
while(L <= R) {
const ll mid = (L + R) >> 1;
if(chk(mid)) R = mid - 1;
else L = mid + 1;
}
printf("%lld\n", L);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3752kb
input:
3 5 1 1 3 7 3 4 4 3 5 10 1 10 100 3 10 100 10 1000 10 10000
output:
2 0 1000000001
result:
wrong answer 3rd lines differ - expected: '-1', found: '1000000001'