Submission #485100

#TimeUsernameProblemLanguageResultExecution timeMemory
485100largefenceBalloons (CEOI11_bal)C++17
70 / 100
2099 ms6424 KiB
#include <bits/stdc++.h>
using namespace std;

#define pw2(x) ((x)*(x))

double x[200000], r[200000], pck[200000];
int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    //freopen("ws.INP", "r", stdin);
	//freopen("ws.OUT", "w", stdout);

	int n; scanf("%d", &n);
	for (int i = 0; i < n; i++)
        scanf("%lf %lf", &x[i], &r[i]);//cin >> x[i] >> r[i];
    pck[0] = r[0]; printf("%.3lf\n", pck[0]);
    int jj = 0;
    for (int i = 1; i < n; i++) {
        pck[i] = r[i];
        /*
        if distance between 2 center < sum of rad of circles => intersect
        ^ <=> sqrt((x[i] - x[j])^2 + (h[i] - h[j])^2) == h[i] + h[j] => maximal
        */
        for (int j = jj; j < i; j++)
            pck[i] = min(pck[i], pw2(x[i] - x[j]) / (4.0 * pck[j]));
        while (pck[jj] < pck[i]) jj++; // if before and not bigger it is definitely not a candidate
        printf("%.3lf\n", pck[i]);
    }
    return 0;
}

// How to AC ?

Compilation message (stderr)

bal.cpp: In function 'int main()':
bal.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  int n; scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
bal.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%lf %lf", &x[i], &r[i]);//cin >> x[i] >> r[i];
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...