#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int inf=2e9, MX=300010;
struct edge{
ll x=1, y=0;
bool operator > (const edge &e) const {
return y*e.x>e.y*x;
}
bool operator == (const edge &e) const {
return y*e.x==e.y*x;
}
};
edge E[MX];
struct node{
int idx;
bool operator > (const node &nd) const {
int a=idx, b=nd.idx;
ll p=E[a].y*E[b].x, q=E[b].y*E[a].x;
return p>q || (p==q && a > b);
}
};
set<int> S1;
set<node, greater<node>> S2;
int n;
ll X[MX], Y[MX];
ll c;
int gcd(int x, int y){
if(y==0) return x;
return gcd(y,x%y);
}
inline ll area(int l, int r){
return (X[r]-X[l])*(Y[l]+Y[r]);
}
int main(){
ios::sync_with_stdio(0); cin.tie(0);
cin>>n>>c; c*=2;
for(int i=1; i<=n; i++) cin>>X[i];
for(int i=1; i<=n; i++) cin>>Y[i];
for(int i=1; i<n; i++){
edge e;
e.x=X[i+1]-X[i];
e.y=Y[i+1]-Y[i];
E[i]=e;
}
for(int i=1; i<n; i++){
S1.insert(i);
S2.insert({i});
}
for(auto x:S2) cout<<x.idx<<' ';
cout<<'\n';
while(true){
int i=S2.begin()->idx;
if(i==1) break;
int j=*prev(S1.find(i));
int k=n;
auto it=S1.find(i);
if(next(it)!=S1.end()) k=*next(it);
ll now=area(j,k)-area(j,i)-area(i,k);
if(now>c) break;
cout<<"POINTS: "<<j<<' '<<i<<' '<<k<<'\n';
c-=now;
S1.erase(i), S2.erase({i});
S1.erase(j), S2.erase({j});
edge g; g.x=E[i].x+E[j].x, g.y=E[i].y+E[j].y;
S1.insert(j), S2.insert({j}); E[j]=g;
cout<<S1.size()<<", "<<S2.size()<<'\n';
}
{
edge ans=E[S2.begin()->idx];
int x=ans.x, y=ans.y, g=gcd(x,y);
cout<<y/g<<"/"<<x/g<<'\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |