QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#479126#4739. Pionektjsyykkk0 0ms3892kbC++11886b2024-07-15 15:13:432024-07-15 15:13:44

Judging History

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

  • [2024-07-15 15:13:44]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3892kb
  • [2024-07-15 15:13:43]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,ans;
struct vec{
	int x,y;
	vec friend operator+(vec a,vec b){
		return {a.x+b.x,a.y+b.y};
	}
	vec friend operator-(vec a,vec b){
		return {a.x-b.x,a.y-b.y};
	}
	int norm(){
		return x*x+y*y;
	}
	int det(vec b){
		return x*b.y-y*b.x;
	}
	int dot(vec b){
		return x*b.x+y*b.y;
	}
}v[200005];
bool cmp(vec a,vec b){
	if(a.y*b.y<0)return a.y>b.y;
	return a.det(b)>0;
}
signed main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)scanf("%lld%lld",&v[i].x,&v[i].y);
	sort(v+1,v+n+1,cmp);
	//for(int i=1;i<=n;i++)cout<<v[i].x<<" "<<v[i].y<<endl;
	vec now={0,0};
	for(int i=1,l=1,r=0;i<=n;i++){
		while(r+1<=n&&v[i].dot(v[r+1])>=0)r++,now=now+v[r];
		while(l<=i&&v[l].dot(v[i])<0)now=now-v[l],l++;
		ans=max(ans,now.norm());
		//cout<<i<<" "<<l<<" "<<r<<endl;
	}
	printf("%lld",ans);
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 15
Accepted
time: 0ms
memory: 3892kb

input:

5
2 -2
-2 -2
0 2
3 1
-3 1

output:

26

result:

ok 1 number(s): "26"

Test #2:

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

input:

1
-2 3

output:

13

result:

ok 1 number(s): "13"

Test #3:

score: -15
Wrong Answer
time: 0ms
memory: 3804kb

input:

20
-3 -8
-5 -5
-4 2
4 -4
-5 -4
-8 9
-4 1
-2 -3
2 0
-2 -10
-7 7
4 3
-7 2
-5 -3
-9 -9
1 6
7 -9
-8 8
7 -9
10 -2

output:

4589

result:

wrong answer 1st numbers differ - expected: '4930', found: '4589'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%