답안 #133160

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
133160 2019-07-20T08:15:22 Z sealnot123 Mobile (BOI12_mobile) C++14
4 / 100
327 ms 32572 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;
	scanf("%d %lld",&n,&L);
	for(i=1;i<=n;i++){
		scanf("%lld%lld",&a,&b);
		tower[i] = {-a*2, a*a + b*b};
	}
	sort(tower+1, tower+1+n, cmp);
    for(i=1;i<=n;i++) add(tower[i]);
    LD ans = 0;
    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, min(calc(tmp2, i), calc(tmp2, i+1)) + tmp2*tmp2);
    }
    for(i=0; i<SZ(line)-1; i++){
    	if(calc(0, i) <= calc(0, i+1)) break;
    }
    ans = max(ans, calc(0, i));
    for(i=0; i<SZ(line)-1; i++){
    	if(calc(L, i) <= calc(L, i+1)) break;
    }
    ans = max(ans, calc(L, i) + L*L);
    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:54: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:56: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 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 424 KB Output is correct
2 Correct 4 ms 504 KB Output is correct
3 Incorrect 3 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 4 ms 508 KB Output is correct
3 Incorrect 3 ms 504 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 1656 KB Output is correct
2 Correct 26 ms 2552 KB Output is correct
3 Correct 17 ms 1784 KB Output is correct
4 Correct 29 ms 2396 KB Output is correct
5 Incorrect 15 ms 1440 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 1528 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 3824 KB Output is correct
2 Correct 27 ms 1656 KB Output is correct
3 Correct 28 ms 4756 KB Output is correct
4 Incorrect 42 ms 2808 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 1940 KB Output is correct
2 Incorrect 34 ms 2880 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 2992 KB Output is correct
2 Incorrect 33 ms 2936 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 166 ms 16484 KB Output is correct
2 Correct 168 ms 8156 KB Output is correct
3 Correct 158 ms 8184 KB Output is correct
4 Incorrect 205 ms 9492 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 163 ms 8200 KB Output is correct
2 Correct 160 ms 9332 KB Output is correct
3 Incorrect 142 ms 11300 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 198 ms 26268 KB Output is correct
2 Incorrect 194 ms 9680 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 194 ms 9720 KB Output is correct
2 Correct 200 ms 11064 KB Output is correct
3 Incorrect 169 ms 12752 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 227 ms 27792 KB Output is correct
2 Incorrect 231 ms 11328 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 231 ms 11512 KB Output is correct
2 Correct 226 ms 12516 KB Output is correct
3 Incorrect 202 ms 14316 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 247 ms 29520 KB Output is correct
2 Incorrect 262 ms 13008 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 265 ms 12816 KB Output is correct
2 Correct 257 ms 14064 KB Output is correct
3 Incorrect 231 ms 15980 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 306 ms 32572 KB Output is correct
2 Incorrect 320 ms 16052 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 327 ms 16012 KB Output is correct
2 Correct 321 ms 18104 KB Output is correct
3 Incorrect 289 ms 21012 KB Output isn't correct
4 Halted 0 ms 0 KB -