QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#661011 | #9427. Collect the Coins | wangmarui | WA | 0ms | 3676kb | C++14 | 3.1kb | 2024-10-20 14:17:59 | 2024-10-20 14:18:05 |
Judging History
answer
/*
time:2024/10/19
contest : http://zhengruioi.com/contest/1702
*/
#include<bits/stdc++.h>
using namespace std;
//#define map unordered_map
#define re register
#define ll long long
#define forl(i,a,b) for(re ll (i)=(a);i<=(b);(i)++)
#define forr(i,a,b) for(re ll (i)=(a);i>=(b);(i)--)
#define forll(i,a,b,c) for(re ll (i)=(a);i<=(b);(i)+=(c))
#define forrr(i,a,b,c) for(re ll (i)=(a);i>=(b);(i)-=(c))
#define pii pair<ll,ll>
#define mid ((l+r)>>1)
#define lowbit(x) (x&-x)
#define pb push_back
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define endl '\n'
#define QwQ return 0;
#define db long double
#define ull unsigned long long
#define lcm(x,y) (1ll*(x)/__gcd(x,y)*(y))
#define Sum(x,y) (1ll*((x)+(y))*((y)-(x)+1)/2)
#define x first
#define y second
#define aty cout<<"Yes\n";
#define atn cout<<"No\n";
#define cfy cout<<"YES\n";
#define cfn cout<<"NO\n";
#define xxy cout<<"yes\n";
#define xxn cout<<"no\n";
#define printcf(x) x?cout<<"YES\n":cout<<"NO\n";
#define printat(x) x?cout<<"Yes\n":cout<<"No\n";
#define printxx(x) x?cout<<"yes\n":cout<<"no\n";
#define maxqueue priority_queue<ll>
#define minqueue priority_queue<ll,vector<ll>,greater<ll>>
#define bug cout<<"---------------------------------------\n";
//ll pw(ll x,ll y,ll mod){if(y==0)return 1;if(x==0)return 0;ll an=1,tmp=x;while(y){if(y&1)an=(an*tmp)%mod;tmp=(tmp*tmp)%mod;y>>=1;}return an;}
template<typename T1,typename T2>bool Max(T1&x,T2 y){if(y>x)return x=y,1;return 0;}
template<typename T1,typename T2>bool Min(T1&x,T2 y){if(y<x)return x=y,1;return 0;}
ll _t_;
void _clear(){}
ll n;
struct node{
int x,y;
}a[1000010];
bool cmp(node x,node y) {
return x.x<y.x;
}
bool check(ll x)
{
ll nx=-1,ny=-1,tx=-1,ty=-1;
forl(i,1,n)
{
ll pd=0;
if(nx==-1)
{
tx=a[i].x,
nx=a[i].y;
pd=1;
}
else
{
ll now=a[i].x-tx;
if(x*now>=abs(nx-a[i].y))
{
tx=a[i].x,
nx=a[i].y;
pd=1;
}
else
{
if(ny==-1)
{
ty=a[i].x,
ny=a[i].y;
pd=1;
}
else
{
ll now=a[i].x-ty;
if(x*now>=abs(ny-a[i].y))
{
ty=a[i].x;
ny=a[i].y;
pd=1;
}
}
}
}
if(!pd)
return 0;
}
return 1;
}
void solve()
{
cin>>n;
forl(i,1,n)
cin>>a[i].x>>a[i].y;
sort(a+1,a+1+n,cmp);
ll L=0,R=4e9;
while(L<R)
{
ll Mid=(L+R)/2;
if(check(Mid))
R=Mid;
else
L=Mid+1;
}
cout<<L<<endl;
}
int main()
{
// freopen("tst.txt","r",stdin);
// freopen("sans.txt","w",stdout);
IOS;
_t_=1;
// cin>>_t_;
while(_t_--)
solve();
QwQ;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3676kb
input:
3 5 1 1 3 7 3 4 4 3 5 10 1 10 100 3 10 100 10 1000 10 10000
output:
0
result:
wrong answer 1st lines differ - expected: '2', found: '0'