QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#444432#8524. Weather Forecastucup-team1198#WA 2ms4036kbC++201.2kb2024-06-15 19:10:012024-06-15 19:10:01

Judging History

你现在查看的是最新测评结果

  • [2024-06-15 19:10:01]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:4036kb
  • [2024-06-15 19:10:01]
  • 提交

answer

#include <map>
#include <set>
#include <array>
#include <cmath>
#include <deque>
#include <bitset>
#include <random>
#include <string>
#include <vector>
#include <cassert>
#include <complex>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>

using namespace std;

using ld = long double;

int get_seq(const vector<ld>& a) {
  vector<ld> val;
  for (ld x : a) {
    if (x < a[0] || x > a.back()) continue;
    int ind = upper_bound(val.begin(), val.end(), x) - val.begin();
    if (ind == val.size()) val.push_back(1e4);
    val[ind] = min(val[ind], x);
  }
  return val.size();
}


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }

  ld l = 0, r = 2e3;
  for (int _ = 0; _ < 60; ++_) {
    ld m = (l + r) / 2;
    vector<ld> pref = {0};
    for (int i = 0; i < n; ++i) {
      pref.push_back(pref[i] + a[i] - m);
    }
    if (get_seq(pref) >= k + 1) {
      l = m;
    } else {
      r = m;
    }
  }

  cout << fixed << setprecision(20);
  cout << (l + r) / 2 << "\n";

  
  return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3884kb

input:

7 3
1 3 1 2 2 2 1

output:

1.66666666666666612312

result:

ok found '1.66667', expected '1.66667', error '0.00000'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3728kb

input:

1 1
1

output:

1.00000000000000002082

result:

ok found '1.00000', expected '1.00000', error '0.00000'

Test #3:

score: 0
Accepted
time: 0ms
memory: 4036kb

input:

2 1
2 1

output:

1.50000000000000046491

result:

ok found '1.50000', expected '1.50000', error '0.00000'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

3 2
2 4 4

output:

3.00000000000000006245

result:

ok found '3.00000', expected '3.00000', error '0.00000'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

4 2
6 7 3 12

output:

6.49999999999999970163

result:

ok found '6.50000', expected '6.50000', error '0.00000'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

5 3
17 23 13 12 21

output:

16.49999999999999990979

result:

ok found '16.50000', expected '16.50000', error '0.00000'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3748kb

input:

7 4
3 37 46 23 46 6 31

output:

23.00000000000000047878

result:

ok found '23.00000', expected '23.00000', error '0.00000'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3792kb

input:

10 5
30 91 36 53 74 91 37 1 76 3

output:

39.49999999999999952122

result:

ok found '39.50000', expected '39.50000', error '0.00000'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3752kb

input:

100 50
593 336 577 842 505 78 665 825 990 895 952 782 721 242 421 951 786 994 238 154 356 483 686 143 220 473 920 353 738 690 96 915 913 157 412 882 465 585 963 635 68 72 901 143 50 558 310 504 987 97 588 987 841 829 780 497 758 909 503 585 91 657 912 870 663 606 748 492 175 92 375 768 773 206 676 8...

output:

482.99999999999999963918

result:

ok found '483.00000', expected '483.00000', error '0.00000'

Test #10:

score: -100
Wrong Answer
time: 2ms
memory: 3976kb

input:

1000 500
74 796 330 98 801 45 160 90 432 788 873 109 714 307 407 94 360 136 198 912 744 902 549 398 478 590 663 983 956 267 201 332 610 249 698 268 700 755 902 485 327 539 203 397 721 971 951 378 674 159 269 182 473 993 84 832 808 908 73 608 842 411 465 886 348 153 924 871 729 1 279 949 475 71 982 3...

output:

487.64893617021276647772

result:

wrong answer 1st numbers differ - expected: '395.00000', found: '487.64894', error = '92.64894'