Submission #712527

# Submission time Handle Problem Language Result Execution time Memory
712527 2023-03-19T04:11:11 Z yuseok0803 Balloons (CEOI11_bal) C++14
100 / 100
105 ms 8876 KB
#include <stdio.h>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stack>
#include <ctype.h>
#define p(x,y) pair<x, y>
#define pii pair<int, int>
#define v(x) vector<x>
#define q(x) queue<x>
#define pq(x) priority_queue<x>
#define uppq(x, comp) priority_queue<x, vector<x>, comp>
#define st(x) set<x>  
#define m(x, y) map<x, y>
#define fi(s,e) for(int i=s;i<e;i++)
#define fj(s,e) for(int j=s;j<e;j++)
#define fk(s,e) for(int k=s;k<e;k++)
typedef long long int ll;
typedef unsigned long long int ull;
typedef __int128 ulll;
using namespace std;

int x[200010];
int r[200010];
double ans[200010];
stack<int> bal;

int main(void){
	int n;
	scanf("%d",&n);
	fi(0,n){
		scanf("%d%d",&x[i],&r[i]);
		ans[i]=r[i];
		
		while(bal.size()){
			ans[i] = min(ans[i], (double)(0.25*(x[i]-x[bal.top()])*(x[i]-x[bal.top()])/ans[bal.top()]));
			
			if(ans[i] > ans[bal.top()]) bal.pop();
			else break;
		}
		
		bal.push(i);
	}
	
	fi(0,n) printf("%.3lf\n", ans[i]);
	return 0;
}

Compilation message

bal.cpp: In function 'int main()':
bal.cpp:35:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
bal.cpp:37:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |   scanf("%d%d",&x[i],&r[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 11 ms 676 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1484 KB 50000 numbers
2 Correct 27 ms 2396 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 53 ms 2748 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 62 ms 3140 KB 115362 numbers
2 Correct 65 ms 5496 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 84 ms 4088 KB 154271 numbers
2 Correct 89 ms 8864 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 105 ms 4880 KB 200000 numbers
2 Correct 91 ms 8876 KB 199945 numbers