QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#102199#4368. Oilfzj2007WA 232ms3492kbC++142.2kb2023-05-02 15:50:402023-05-02 15:50:41

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-02 15:50:41]
  • 评测
  • 测评结果:WA
  • 用时:232ms
  • 内存:3492kb
  • [2023-05-02 15:50:40]
  • 提交

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];
struct node{
	int dx,dy,val;
	node(int _dx=0,int _dy=0,int _val=0):dx(_dx),dy(_dy),val(_val){}
	inline bool operator<(const node &b)const{
		return (ll)dx*b.dy<(ll)b.dx*dy;
	}
	inline bool operator==(const node &b)const{
		return (ll)dx*b.dy==(ll)dy*b.dx;
	}
}t[N];
int n;
ll ans;
inline ll solve(int x,int y){
	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,p[i].r-p[i].l);
		t[++m]=node(p[i].h-y,p[i].r-x,-p[i].r+p[i].l);
	}
	sort(t+1,t+m+1);
	ll val=0;
	for(int i=1;i<=m;){
		int j=i;ll del=0;
		if(t[i].val>0) val+=t[i].val;
		else del+=t[i].val;
		while(j+1<=m&&t[j]==t[j+1]){
			j++;
			if(t[j].val>0) val+=t[j].val;
			else del+=t[j].val;
		}
		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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3284kb

input:

5
100 180 20
30 60 30
70 110 40
10 40 50
0 80 70

output:

200

result:

ok single line: '200'

Test #2:

score: 0
Accepted
time: 2ms
memory: 3276kb

input:

3
50 60 10
-42 -42 20
25 0 10

output:

25

result:

ok single line: '25'

Test #3:

score: 0
Accepted
time: 2ms
memory: 3264kb

input:

1
-100 180 20

output:

280

result:

ok single line: '280'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3340kb

input:

1
-1000000 1000000 1

output:

2000000

result:

ok single line: '2000000'

Test #5:

score: 0
Accepted
time: 2ms
memory: 3492kb

input:

1
-1000000 1000000 1000000

output:

2000000

result:

ok single line: '2000000'

Test #6:

score: 0
Accepted
time: 2ms
memory: 3308kb

input:

1
-1000000 -999999 1000000

output:

1

result:

ok single line: '1'

Test #7:

score: 0
Accepted
time: 2ms
memory: 3308kb

input:

1
1000000 999999 1000000

output:

1

result:

ok single line: '1'

Test #8:

score: 0
Accepted
time: 1ms
memory: 3308kb

input:

2
-1000 0 200
1 1000 200

output:

1000

result:

ok single line: '1000'

Test #9:

score: -100
Wrong Answer
time: 232ms
memory: 3412kb

input:

1000
737368 429284 959063
-548693 513523 43074
243164 -465669 860567
422975 -244747 588631
-136535 -470055 501433
-580596 -269833 22422
476738 -448258 866889
358773 563858 950905
-923261 208187 66835
-295330 444422 360513
-903435 841952 491761
377801 520064 65247
479135 -307498 426574
-794533 -46924...

output:

489061674

result:

wrong answer 1st lines differ - expected: '490622362', found: '489061674'