Submission #133141

# Submission time Handle Problem Language Result Execution time Memory
133141 2019-07-20T07:56:06 Z sealnot123 Mobile (BOI12_mobile) C++14
4 / 100
346 ms 32468 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*2ll, 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, calc(tmp2, i) + 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",(double)sqrt(ans));
    return 0;
}
/*
2 10
0 0
11 1
*/

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);
   ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Incorrect 3 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Incorrect 3 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 26 ms 1760 KB Output is correct
2 Correct 28 ms 1528 KB Output is correct
3 Correct 18 ms 1144 KB Output is correct
4 Correct 29 ms 1516 KB Output is correct
5 Incorrect 16 ms 1272 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 1656 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 28 ms 3892 KB Output is correct
2 Correct 29 ms 1656 KB Output is correct
3 Correct 29 ms 3816 KB Output is correct
4 Incorrect 44 ms 2044 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 36 ms 1884 KB Output is correct
2 Incorrect 35 ms 1872 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 38 ms 3032 KB Output is correct
2 Incorrect 34 ms 1912 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 157 ms 16448 KB Output is correct
2 Correct 173 ms 8192 KB Output is correct
3 Correct 167 ms 8100 KB Output is correct
4 Incorrect 215 ms 8888 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 173 ms 8088 KB Output is correct
2 Correct 170 ms 9284 KB Output is correct
3 Incorrect 150 ms 10344 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 193 ms 26228 KB Output is correct
2 Incorrect 204 ms 9720 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 207 ms 9672 KB Output is correct
2 Correct 205 ms 10900 KB Output is correct
3 Incorrect 178 ms 11884 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 233 ms 27884 KB Output is correct
2 Incorrect 243 ms 11384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 246 ms 11228 KB Output is correct
2 Correct 241 ms 12400 KB Output is correct
3 Incorrect 215 ms 13420 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 261 ms 29452 KB Output is correct
2 Incorrect 278 ms 12908 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 280 ms 12920 KB Output is correct
2 Correct 272 ms 13988 KB Output is correct
3 Incorrect 244 ms 15004 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 318 ms 32468 KB Output is correct
2 Incorrect 342 ms 16136 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 346 ms 15992 KB Output is correct
2 Correct 338 ms 18216 KB Output is correct
3 Incorrect 306 ms 20196 KB Output isn't correct
4 Halted 0 ms 0 KB -