Submission #1047119

#TimeUsernameProblemLanguageResultExecution timeMemory
1047119RequiemBalloons (CEOI11_bal)C++17
40 / 100
22 ms7104 KiB
#include<bits/stdc++.h> #define int long long #define pb push_back #define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); #define MOD 1000000007 #define inf 1e18 #define fi first #define se second #define FOR(i,a,b) for(int i=a;i<=b;i++) #define FORD(i,a,b) for(int i=a;i>=b;i--) #define sz(a) ((int)(a).size()) #define endl '\n' #define pi 3.14159265359 #define TASKNAME "" using namespace std; /**Debugging Tool **/ void __print(int x) {cerr << x;} void __print(unsigned x) {cerr << x;} void __print(unsigned long x) {cerr << x;} void __print(unsigned long long x) {cerr << x;} void __print(float x) {cerr << x;} void __print(double x) {cerr << x;} void __print(long double x) {cerr << x;} void __print(char x) {cerr << '\'' << x << '\'';} void __print(const char *x) {cerr << '\"' << x << '\"';} void __print(const string &x) {cerr << '\"' << x << '\"';} void __print(bool x) {cerr << (x ? "true" : "false");} template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';} template<typename T> void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";} template <typename T, typename... V> void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);} #ifndef ONLINE_JUDGE #define debug(x...) cerr << "[" << #x << "] = ["; _print(x) #else #define debug(x...) #endif /*----------------------------------*/ /** Vector nhieu chieu **/ template<int D, typename T> struct Vec: public vector<Vec<D - 1, T>>{ static_assert(D >= 1, "vector dimensions must be greater than 0"); template<typename... Args> Vec(int n = 0, Args... args): vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)){ } }; template<typename T> struct Vec<1, T>: public vector<T> { Vec(int n = 0, const T& val = T()): vector<T>(n, val) {}; }; /*--------------------------------*/ template<typename T> bool maximize(T &res, const T &val) { if (res < val){ res = val; return true; }; return false; } template<typename T> bool minimize(T &res, const T &val) { if (res > val){ res = val; return true; }; return false; } typedef pair<int,int> ii; typedef pair<int,ii> iii; typedef vector<int> vi; #define eps 1e-4 /** * Cho n quả bóng với 2 thông số là Xi và Ri, tương ứng là vị trí bơm và bán kính bơm tối đa. * Ta bơm tuần tự từ quả bóng thứ 1 đến quả bóng thứ n. * Với quả bóng thứ i, ta bơm cho đến khi nó chạm vào quả bóng khác hoặc nó đạt bán kính tối đa * Giả sử ta đang có cấu hình là (x1, r1), (x2, r2), ... Khi thêm vào (xn, rn) thì bài toán sẽ thay đổi ntn * */ const int MAXN = 3e5 + 9; struct balloon{ int position; int maxDiameter; } B[MAXN]; int n; void input(){ cin >> n; for(int i = 1; i <= n; i++){ cin >> B[i].position >> B[i].maxDiameter; } } namespace subtask1{ bool check(){ return n <= 2000; } double currentDiameter[MAXN]; void solve(){ for(int i = 1; i <= n; i++){ if (i == 1) currentDiameter[i] = B[i].maxDiameter; else{ currentDiameter[i] = B[i].maxDiameter; for(int j = 1; j < i; j++){ int x1 = B[j].position; int x2 = B[i].position; minimize(currentDiameter[i], 1.0 * (x1 - x2) * (x1 - x2) / (4 * currentDiameter[j])); } } cout << setprecision(3) << fixed << currentDiameter[i] << endl; } cout << endl; } } main() { fast; if (fopen(TASKNAME".inp","r")){ freopen(TASKNAME".inp","r",stdin); freopen(TASKNAME".out","w",stdout); } input(); if (subtask1::check()) return subtask1::solve(), 0; } /** Warning: - MLE / TLE? - Gioi han mang? - Gia tri max phai luon gan cho -INF - long long co can thiet khong? - tran mang. - code can than hon - Nho sinh test de tranh RTE / TLE --> Coi lai truoc khi nop **/

Compilation message (stderr)

bal.cpp:117:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  117 | main()
      | ^~~~
bal.cpp: In function 'int main()':
bal.cpp:121:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  121 |         freopen(TASKNAME".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
bal.cpp:122:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  122 |         freopen(TASKNAME".out","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...