当前位置:网站首页>Jisuanke - t2063_ Missile interception
Jisuanke - t2063_ Missile interception
2022-07-06 01:55:00 【This question AC sleep again】




//
Answer key :
take The distance from the missile to the two systems (d1 d2) Form a structure For missiles to 1 The distance of system No (d1) Sort from big to small
And then we're going to iterate If and only if a[i].d1 + ( 1~i-1 in a[i].d2 The maximum of ) At the very least That's the answer.
Be careful There is such a situation 1 The No. 1 system does not have to intercept any missiles
It is equivalent to dividing the missiles into two piles Ask the sum of their respective maximum values Just arrange the maximum value of one pile first
//
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+6;
typedef struct missile
{
int d1,d2;
}T;
T a[MAXN];
bool cmp( T a,T b )
{
return a.d1>b.d1; // Value of expression
}
int main()
{
int x1,yl,x2,y2,n,i,x,y,maxd2,ans; // yl
while( ~scanf("%d%d%d%d%d",&x1,&yl,&x2,&y2,&n) )
{
memset( a,0,sizeof( a ) );
for( i=0;i<n;i++ )
{
scanf("%d%d",&x,&y);
a[i].d1=( x1-x )*( x1-x )+( yl-y )*( yl-y ); // Negative is positive
a[i].d2=( x2-x )*( x2-x )+( y2-y )*( y2-y );
}
sort( a,a+n,cmp );
ans=a[0].d1; // initialization
maxd2=a[0].d2;
for( i=1;i<=n;i++ ) // i<=n: 1 The system may not need to intercept missiles
{
ans=min( ans,maxd2+a[i].d1 );
maxd2=max( maxd2,a[i].d2 );
}
printf("%d\n",ans);
}
return 0;
}//
find:
01 Calculation scale 1<=N<=1e5,abs<=1e3 --> d<=2*1e8 < int
02 cmp direct return Value of expression
03 Global variables y1 name conflict Just use yl yi wait ( There is a header file defined y1 )
04 Negative is positive
05 Initialization should be in place (a[n]=0) 1 The system may not need to intercept missiles
06 Clarify the logical relationship
00 Why did you think wrong at first
There may be front 1 System The working radius is large
Then suddenly there is a distance 2 System Near some very far missiles
Lead to direct 1 System The working radius of includes
00 Fast reading 边栏推荐
- You are using pip version 21.1.1; however, version 22.0.3 is available. You should consider upgradin
- Win10 add file extension
- 安装Redis
- 【全网最全】 |MySQL EXPLAIN 完全解读
- Internship: unfamiliar annotations involved in the project code and their functions
- 剑指 Offer 12. 矩阵中的路径
- ClickOnce does not support request execution level 'requireAdministrator'
- 干货!通过软硬件协同设计加速稀疏神经网络
- Format code_ What does formatting code mean
- Leetcode3. Implement strstr()
猜你喜欢

【Flask】官方教程(Tutorial)-part2:蓝图-视图、模板、静态文件

Unity learning notes -- 2D one-way platform production method

Computer graduation design PHP part-time recruitment management system for College Students

Computer graduation design PHP campus restaurant online ordering system

同一个 SqlSession 中执行两条一模一样的SQL语句查询得到的 total 数量不一样
![[Jiudu OJ 09] two points to find student information](/img/35/25aac51fa3e08558b1f6e2541762b6.jpg)
[Jiudu OJ 09] two points to find student information

Alibaba-Canal使用详解(排坑版)_MySQL与ES数据同步

How does redis implement multiple zones?

Basic operations of databases and tables ----- unique constraints

Leetcode skimming questions_ Invert vowels in a string
随机推荐
Get the relevant information of ID card through PHP, get the zodiac, get the constellation, get the age, and get the gender
Publish your own toolkit notes using NPM
【Flask】官方教程(Tutorial)-part1:项目布局、应用程序设置、定义和访问数据库
Extracting key information from TrueType font files
Force buckle 9 palindromes
[ssrf-01] principle and utilization examples of server-side Request Forgery vulnerability
Code review concerns
Social networking website for college students based on computer graduation design PHP
Luo Gu P1170 Bugs Bunny and Hunter
Redis-Key的操作
How to get all sequences in Oracle database- How can I get all sequences in an Oracle database?
[le plus complet du réseau] | interprétation complète de MySQL explicite
Computer graduation design PHP animation information website
【SSRF-01】服务器端请求伪造漏洞原理及利用实例
500 lines of code to understand the principle of mecached cache client driver
阿里测开面试题
selenium 元素定位(2)
[the most complete in the whole network] |mysql explain full interpretation
【Flask】静态文件与模板渲染
PHP campus financial management system for computer graduation design