제출 #443745

#제출 시각아이디문제언어결과실행 시간메모리
443745YimingHuang47Balloons (CEOI11_bal)C++14
100 / 100
326 ms10460 KiB
//problem: https://oj.uz/problem/view/CEOI11_bal
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <stack>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vll = vector<vl>;
using vii = vector<vector<int>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define lb lower_bound
#define ub upper_bound 
const int MOD = 1e9+7;
const ll INF = 1e18;
template<class T> bool ckmin(T& a, const T& b){return b < a ? a = b, 1 : 0;}
template<class T> bool ckmax(T& a, const T& b){return a < b ? a = b, 1 : 0;}
void setIO(string name=""){
  freopen((name+".in").c_str(),"r",stdin);
  freopen((name+".out").c_str(),"w",stdout);
}


int N;
const int maxn = 200005;
int P[maxn], R[maxn];
long double fR[maxn];
long double compute(int a, int b){
  return (long double)(P[b]-P[a])*(P[b]-P[a])/(4*fR[a]);
}
int main() {
  //freopen("input.txt","r",stdin);
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> P[i] >> R[i];
  }
  stack<int> s;
  for(int b = 0; b < N; b++){
    fR[b] = R[b];
    while(s.size()){
      int a = s.top();
      long double rB = compute(a,b);
      ckmin(fR[b],rB);
      if(fR[b] > fR[a]){
        s.pop();
      }
      else{
        break;
      }
    }
    s.push(b);
  }
  for(int i = 0; i < N; i++){
    printf("%.3Lf\n",fR[i]);
  }
}

컴파일 시 표준 에러 (stderr) 메시지

bal.cpp: In function 'void setIO(std::string)':
bal.cpp:31:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |   freopen((name+".in").c_str(),"r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bal.cpp:32:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |   freopen((name+".out").c_str(),"w",stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...