QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#102239 | #4368. Oil | fzj2007 | WA | 2ms | 3400kb | C++14 | 2.6kb | 2023-05-02 16:39:21 | 2023-05-02 16:39:24 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
namespace IO{
template<typename T>inline bool read(T &x){
x=0;
char ch=getchar();
bool flag=0,ret=0;
while(ch<'0'||ch>'9') flag=flag||(ch=='-'),ch=getchar();
while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar(),ret=1;
x=flag?-x:x;
return ret;
}
template<typename T,typename ...Args>inline bool read(T& a,Args& ...args){
return read(a)&&read(args...);
}
template<typename T>void prt(T x){
if(x>9) prt(x/10);
putchar(x%10+'0');
}
template<typename T>inline void put(T x){
if(x<0) putchar('-'),x=-x;
prt(x);
}
template<typename T>inline void put(char ch,T x){
if(x<0) putchar('-'),x=-x;
prt(x);
putchar(ch);
}
template<typename T,typename ...Args>inline void put(T a,Args ...args){
put(a);
put(args...);
}
template<typename T,typename ...Args>inline void put(const char ch,T a,Args ...args){
put(ch,a);
put(ch,args...);
}
inline void put(string s){
for(int i=0,sz=s.length();i<sz;i++) putchar(s[i]);
}
inline void put(const char* s){
for(int i=0,sz=strlen(s);i<sz;i++) putchar(s[i]);
}
}
using namespace IO;
#define N 4005
#define ll long long
struct Line{
int l,r,h;
}p[N];
inline int check(ll x){
if(x<0) return -1;
if(x==0) return 0;
if(x>0) return 1;
}
struct node{
int dx,dy,id;
node(int _dx=0,int _dy=0,int _id=0):dx(_dx),dy(_dy),id(_id){}
inline bool operator<(const node &b)const{
int opx=check((ll)dx*dy),opy=check((ll)b.dx*b.dy);
if(opx!=opy) return opx<opy;
if(opx>=0) return (ll)dy*b.dx<(ll)b.dy*dx;
else return (ll)dy*b.dx>(ll)b.dy*dx;
}
inline bool operator==(const node &b)const{
return (ll)dx*b.dy==(ll)dy*b.dx;
}
}t[N];
int n,vis[N];
ll ans;
inline ll solve(int x,int y){
memset(vis,0,sizeof(vis));
ll res=0;int m=0;
for(int i=1;i<=n;i++){
if(p[i].h==y) continue;
t[++m]=node(p[i].h-y,p[i].l-x,i);
t[++m]=node(p[i].h-y,p[i].r-x,i);
}
sort(t+1,t+m+1);
ll val=0;
for(int i=1;i<=m;){
int j=i;ll del=0;
if(!vis[t[j].id]) val+=p[t[j].id].r-p[t[j].id].l,vis[t[j].id]=1;
else del+=p[t[j].id].r-p[t[j].id].l;
while(j+1<=m&&t[j]==t[j+1]){
j++;
if(!vis[t[j].id]) val+=p[t[j].id].r-p[t[j].id].l,vis[t[j].id]=1;
else del+=p[t[j].id].r-p[t[j].id].l;
}
res=max(res,val),val-=del;
i=j+1;
}
return res;
}
int main(){
read(n);
for(int i=1;i<=n;i++){
read(p[i].l,p[i].r,p[i].h);
if(p[i].l>p[i].r) swap(p[i].l,p[i].r);
}
for(int i=1;i<=n;i++)
ans=max(ans,p[i].r-p[i].l+max(solve(p[i].l,p[i].h),solve(p[i].r,p[i].h)));
put('\n',ans);
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3400kb
input:
5 100 180 20 30 60 30 70 110 40 10 40 50 0 80 70
output:
260
result:
wrong answer 1st lines differ - expected: '200', found: '260'