답안 #133166

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
133166 2019-07-20T08:21:22 Z sealnot123 Mobile (BOI12_mobile) C++14
30 / 100
420 ms 37392 KB
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
typedef double D;
typedef long double LD;
const int N = 1000007;
PLL tower[N];

bool cmp(PLL a, PLL b){
	if(a.x != b.x) return a.x > b.x;
	return a.y < b.y;
}

PLL intersect(PLL a, PLL b){
	LL A, B;
	A = a.y - b.y;
	B = b.x - a.x;
	if(B < 0) A = -A, B = -B;
	return {A, B};
}

vector<PLL> line;

void add(PLL nw){
	while(SZ(line)>1){
		int a = SZ(line);
		if(line[a-1].x == nw.x) return;
		PLL tmp1 = intersect(line[a-2], line[a-1]);
		PLL tmp2 = intersect(line[a-1], nw);
		if(tmp2.x*tmp1.y <= tmp1.x*tmp2.y) line.pop_back();
		else break;
	}
	line.pb(nw);
}

LD calc(LD a, int b){
	return a*line[b].x + line[b].y;
}

LL L;
int n;

int main(){
	int i,j;
	LL a,b, dist0 = 2e18, distL = 2e18;
 	LD ans;
	scanf("%d %lld",&n,&L);
	for(i=1;i<=n;i++){
		scanf("%lld%lld",&a,&b);
		dist0 = min(dist0, a*a + b*b);
		distL = min(distL, (L-a)*(L-a) + b*b);
		tower[i] = {-a*2ll, a*a + b*b};
	}
	ans = (LD)max(dist0, distL);
	sort(tower+1, tower+1+n, cmp);
    for(i=1;i<=n;i++) add(tower[i]);
    for(i = 0; i < SZ(line)-1; i++){
    	PLL tmp = intersect(line[i], line[i+1]);
    	LD tmp2 = (LD)tmp.x/tmp.y;
    	if(tmp2 < 0 || tmp2 > L) continue;
    	ans = max(ans, calc(tmp2, i) + tmp2*tmp2);
    }
    printf("%Lf",sqrt(ans));
    return 0;
}
/*
2 10
0 0
11 1

3 10
1 0
5 0
10 0

2 10
-5 3
12 2
*/ 

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:52:8: warning: unused variable 'j' [-Wunused-variable]
  int i,j;
        ^
mobile.cpp:55:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %lld",&n,&L);
  ~~~~~^~~~~~~~~~~~~~~~~
mobile.cpp:57:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld",&a,&b);
   ~~~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 316 KB Output is correct
2 Correct 3 ms 508 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 4 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 4 ms 504 KB Output is correct
4 Correct 4 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 4 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 4 ms 504 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 1796 KB Output is correct
2 Correct 25 ms 1576 KB Output is correct
3 Correct 17 ms 1144 KB Output is correct
4 Correct 29 ms 1528 KB Output is correct
5 Correct 15 ms 1144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 1528 KB Output is correct
2 Correct 25 ms 2424 KB Output is correct
3 Correct 28 ms 2552 KB Output is correct
4 Correct 30 ms 2748 KB Output is correct
5 Incorrect 34 ms 3192 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 3944 KB Output is correct
2 Correct 28 ms 1656 KB Output is correct
3 Correct 31 ms 3844 KB Output is correct
4 Incorrect 45 ms 1920 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 1868 KB Output is correct
2 Correct 33 ms 1912 KB Output is correct
3 Correct 34 ms 3320 KB Output is correct
4 Incorrect 49 ms 3832 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 3048 KB Output is correct
2 Correct 33 ms 1912 KB Output is correct
3 Correct 29 ms 3320 KB Output is correct
4 Incorrect 52 ms 3824 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 150 ms 16596 KB Output is correct
2 Correct 160 ms 8188 KB Output is correct
3 Correct 160 ms 8312 KB Output is correct
4 Incorrect 205 ms 8816 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 169 ms 8308 KB Output is correct
2 Correct 161 ms 9456 KB Output is correct
3 Correct 142 ms 10476 KB Output is correct
4 Incorrect 205 ms 18672 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 185 ms 26228 KB Output is correct
2 Correct 193 ms 9848 KB Output is correct
3 Correct 190 ms 18456 KB Output is correct
4 Incorrect 253 ms 21916 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 196 ms 9720 KB Output is correct
2 Correct 193 ms 11016 KB Output is correct
3 Correct 171 ms 11960 KB Output is correct
4 Incorrect 253 ms 21968 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 215 ms 27856 KB Output is correct
2 Correct 228 ms 11260 KB Output is correct
3 Correct 227 ms 21548 KB Output is correct
4 Incorrect 296 ms 26080 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 229 ms 11328 KB Output is correct
2 Correct 228 ms 12580 KB Output is correct
3 Correct 201 ms 13412 KB Output is correct
4 Incorrect 291 ms 25868 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 243 ms 29352 KB Output is correct
2 Correct 262 ms 13092 KB Output is correct
3 Correct 256 ms 24512 KB Output is correct
4 Incorrect 337 ms 29292 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 261 ms 12808 KB Output is correct
2 Correct 264 ms 13936 KB Output is correct
3 Correct 231 ms 15084 KB Output is correct
4 Incorrect 338 ms 29408 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 308 ms 32592 KB Output is correct
2 Correct 320 ms 16080 KB Output is correct
3 Correct 324 ms 30692 KB Output is correct
4 Incorrect 414 ms 37392 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 328 ms 16032 KB Output is correct
2 Correct 322 ms 18284 KB Output is correct
3 Correct 288 ms 20196 KB Output is correct
4 Incorrect 420 ms 36508 KB Output isn't correct
5 Halted 0 ms 0 KB -