답안 #1077151

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1077151 2024-08-27T01:55:29 Z vjudge1 Bulldozer (JOI17_bulldozer) C++17
0 / 100
24 ms 592 KB
#include <bits/stdc++.h>
using namespace std;
#define ld long double
long double dis(ld a,ld x,ld y)
{
	//y=ax
	//ax-y=0;
	return (abs(a*x-y))/sqrt(a*a+1);
}
struct node
{
	int x,y,w;
}p[2009];
int n;
const ld pi=acos(-1); 
ld rad(ld x)
{
	return x*pi/180;
}
struct pos
{
	bool is;
	ld x;
	long long w;
};
struct cmp
{
	bool operator() (pos a,pos b)
	{
		if(a.is!=b.is)return a.is<b.is;
		return a.x<b.x;
	}
};
const ld E=1e-8;
long long f[2009];
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>p[i].x>>p[i].y>>p[i].w;
	long long kq=0;
	for(ld j=0;j<=360;j+=0.1)
	{
		vector<pos>t;
		ld a=atan(j);
		for(int i=1;i<=n;i++)
		{
			if(p[i].y>=a*p[i].x)t.push_back({1,dis(a,p[i].x,p[i].y),p[i].w});
			else t.push_back({0,dis(a,p[i].x,p[i].y),p[i].w});
		}
		sort(t.begin(),t.end(),cmp());
		int cnt=0;		
		for(int i=1;i<=n;i++)f[i]=0;
		cnt++;
		f[cnt]=t[0].w;
		for(int i=1;i<t.size();i++)
		{
			if(t[i].is==t[i-1].is&&abs(t[i].x-t[i-1].x)<E)f[cnt]+=t[i].w;
			else
			{
				cnt++;
				f[cnt]+=t[i].w;
			}
		}
		long long tam=0, pre = 0;
		for(int i=1;i<=cnt;i++)
		{
			tam += f[i];
			kq = max(kq, tam - pre);
			pre = min(pre, tam);
			// tam=max(tam,tam+f[i]);
			// tam=max(tam,0*1ll);
			// tam=max(tam,f[i]);
		}
		kq=max(kq,tam);
		// if(tam==21)
		// {
		// 	for(int i=1;i<=cnt;i++)cout<<f[i]<<'\n';
		// 	cout<<'\n';
		// }
	}
	cout<<kq;
	return 0;
}

Compilation message

bulldozer.cpp: In function 'int main()':
bulldozer.cpp:58:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<pos>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |   for(int i=1;i<t.size();i++)
      |               ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 348 KB Output is correct
2 Correct 24 ms 592 KB Output is correct
3 Correct 17 ms 348 KB Output is correct
4 Correct 19 ms 348 KB Output is correct
5 Correct 16 ms 476 KB Output is correct
6 Incorrect 16 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 348 KB Output is correct
2 Correct 24 ms 592 KB Output is correct
3 Correct 17 ms 348 KB Output is correct
4 Correct 19 ms 348 KB Output is correct
5 Correct 16 ms 476 KB Output is correct
6 Incorrect 16 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -