QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#456913 | #8524. Weather Forecast | supepapupu | WA | 0ms | 4056kb | C++20 | 1.1kb | 2024-06-28 16:57:26 | 2024-06-28 16:57:29 |
Judging History
answer
#include <bits/stdc++.h>
#define x first
#define y second
#define el '\n'
#define debug(x) cerr << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 1e6 + 10, INF = 0x3f3f3f3f, mod = 998244353;
int lis(vector<double> &a) {
int n = a.size(), len = 0;
vector<double> f(n + 1);
for (int i = 0; i < n; ++i) {
int l = 0, r = len, mid;
while (l < r) {
mid = l + r + 1 >> 1;
if (f[mid] < a[i]) l = mid;
else r = mid - 1;
}
len = max(len, r + 1);
f[r + 1] = a[i];
if (i + 1 == n) return r;
}
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int n, k; cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; ++i) cin >> a[i];
double l = 1, r = 1000, mid;
for (int i = 0; i < 30; ++i) {
mid = (l + r) / 2;
vector<double> s(n + 1);
for (int i = 1; i <= n; ++i) s[i] = s[i - 1] + a[i - 1] - mid;
if (lis(s) >= k) l = mid;
else r = mid;
}
cout << format("{:.8f}", l) << el;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 4056kb
input:
7 3 1 3 1 2 2 2 1
output:
1.66666627
result:
ok found '1.66667', expected '1.66667', error '0.00000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3912kb
input:
1 1 1
output:
1.00000000
result:
ok found '1.00000', expected '1.00000', error '0.00000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
2 1 2 1
output:
1.49999970
result:
ok found '1.50000', expected '1.50000', error '0.00000'
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3828kb
input:
3 2 2 4 4
output:
3.99999914
result:
wrong answer 1st numbers differ - expected: '3.00000', found: '4.00000', error = '1.00000'