Submission #115344

# Submission time Handle Problem Language Result Execution time Memory
115344 2019-06-06T18:10:16 Z model_code Balloons (CEOI11_bal) C++17
50 / 100
2000 ms 1772 KB
/* Slow solution for the task BAL (Balloons)
 * Author: Jakub Pachocki
 * O(n^2) 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;
		for (int j = ss - 1; j >= 0; --j) {
			long double c = sq(s[j].x - pos);
			maxRadius = min(maxRadius, c / (4 * s[j].radius));
		}
		printf("%.3Lf\n", maxRadius);
		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 2 ms 256 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 11 ms 384 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 871 ms 1228 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Execution timed out 2057 ms 1756 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2043 ms 1612 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 2045 ms 1568 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2051 ms 1772 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2052 ms 1656 KB Time limit exceeded
2 Halted 0 ms 0 KB -