Submission #115343

# Submission time Handle Problem Language Result Execution time Memory
115343 2019-06-06T18:07:13 Z model_code Balloons (CEOI11_bal) C++17
20 / 100
142 ms 2020 KB
/* Model solution for the task BAL (Balloons)
 * Author: Jakub Pachocki
 * O(n) time solution
 */

#include <cstdio>
#include <algorithm>

using namespace std;

struct Balloon {
	int x;
	long double radius;
};

long double sq(long double x) {
	return x * x;
}

Balloon s[200000];
int ss;

int n;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		int pos;
		scanf("%d", &pos);
		int size;
		scanf("%d", &size);
		long double maxRadius = size;
		while (ss > 0) {
			long double c = sq(s[ss - 1].x - pos);
			maxRadius = min(maxRadius, c / (4 * s[ss - 1].radius));
			if (maxRadius > s[ss - 1].radius - 1e-10)
				--ss;
			else
				break;
		}
		printf("%.3Lf\n", maxRadius + 1e-3);
		s[ss].x = pos;
		s[ss].radius = maxRadius;
		++ss;
	}
}

Compilation message

bal.cpp: In function 'int main()':
bal.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
bal.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &pos);
   ~~~~~^~~~~~~~~~~~
bal.cpp:31:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &size);
   ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB 85th numbers differ - expected: '3.0620000000', found: '3.0640000000', error = '0.0020000000'
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 412 KB 393rd numbers differ - expected: '3.0620000000', found: '3.0640000000', error = '0.0020000000'
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 528 KB 8963rd numbers differ - expected: '3.0620000000', found: '3.0640000000', error = '0.0020000000'
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 1096 KB 36751st numbers differ - expected: '1.5620000000', found: '1.5640000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 78 ms 1476 KB 17873rd numbers differ - expected: '3.0620000000', found: '3.0640000000', error = '0.0020000000'
# Verdict Execution time Memory Grader output
1 Incorrect 90 ms 1692 KB 4948th numbers differ - expected: '0.2200000000', found: '0.2220000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 121 ms 1900 KB 12331st numbers differ - expected: '3.0620000000', found: '3.0640000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 142 ms 2020 KB 6256th numbers differ - expected: '0.5620000000', found: '0.5640000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -