题解:P16992 [NWERC 2018] 充气 / Inflation
Description
给定序列
Analysis
先给结论:将
证明:
对于当前的两个位置
无解也很好判断,若 impossible 即可。
时间复杂度
Code
#include"bits/stdc++.h"
using namespace std;
const int N = 2e5 + 5;
int n, c[N];
signed main() {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
cin >> n;
for (int i = 1; i <= n; i++)
cin >> c[i];
sort(c + 1, c + 1 + n);
for (int i = 1; i <= n; i++)
if (c[i] > i) {
cout << "impossible";
return 0;
}
double ans = 1;
for (int i = 1; i <= n; i++)
ans = min(ans, (double)c[i] / i);
cout << ans;
return 0;
}