QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#752390#9540. Double 11hos_lyricWA 667ms14272kbC++143.7kb2024-11-16 01:36:232024-11-16 01:36:25

Judging History

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

  • [2024-11-16 01:36:25]
  • 评测
  • 测评结果:WA
  • 用时:667ms
  • 内存:14272kb
  • [2024-11-16 01:36:23]
  • 提交

answer

// modified https://qoj.ac/submission/750888

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")


using Double = long double;
// using Pair = pair<Double, int>;
// Pair operator+(Pair a, Pair b) { return Pair(a.first + b.first, a.second + b.second); }

template <class T> struct MonotoneMinDP {
vector<int> que, pos;
vector<pair<T, int>> ts;

template <class Cost> pair<T, int> run(int n, Cost cost, Double w) {
  auto get = [&](int l, int r) -> pair<T, int> {
    return make_pair(ts[l].first + cost(l, r) + w, ts[l].second + 1);
  };
  que.resize(n + 1);
  pos.resize(n + 1);
  ts.resize(n + 1);
  int head = 1, tail = 0;
  ts[0] = make_pair(0, 0);
  for (int i = 1; i <= n; ++i) {
    ts[i] = get(0, i);
    while (head < tail && pos[head + 1] <= i) head++;
    if (head <= tail) {
      if (get(que[head], i) < ts[i]) ts[i] = get(que[head], i);
      while (head < tail && pos[head + 1] <= i + 1) head++;
      if (head <= tail) pos[head] = i + 1;
    }
    //
    int r = n;
    while (head <= tail) {
      if (get(que[tail], pos[tail]) > get(i, pos[tail])) r = pos[tail] - 1, tail--;
      else if (get(que[tail], r) <= get(i, r)) {
        if (r < n) que[++tail] = i, pos[tail] = r + 1;
        break;
      } else {
        int L = pos[tail], R = r;
        while (L < R) {
          int M = (L + R) >> 1;
          if (get(que[tail], M) <= get(i, M)) L = M + 1;
          else
            R = M;
        }
        que[++tail] = i, pos[tail] = L;
        break;
      }
    }
    if (head > tail) {
      que[++tail] = i;
      pos[tail] = i + 1;
    }
  }
  return ts[n];
}
};  // MonotoneMinDP


int N, M;
vector<Int> S, SSum;

int main() {
  for (; ~scanf("%d%d", &N, &M); ) {
    S.resize(N);
    for (int i = 0; i < N; ++i) scanf("%lld", &S[i]);
    sort(S.begin(), S.end());
    
    SSum.assign(N + 1, 0);
    for (int i = 0; i < N; ++i) SSum[i + 1] = SSum[i] + S[i];
    
    MonotoneMinDP<Double> f;
    auto calc = [&](Double pena) -> pair<Double, int> {
      return f.run(N, [&](int l, int r) -> Double {
        return sqrt((Double)((r - l) * (SSum[r] - SSum[l])));
      }, pena);
    };
    
    Double lo = -100, hi = 1e9;
    for (int iter = 0; iter < 60; ++iter) {
      const Double mid = (lo + hi) / 2;
      const auto res = calc(mid);
      ((res.second >= M) ? lo : hi) = mid;
    }
    const auto res = calc(lo);
    printf("%.12Lf\n", res.first - res.second * lo);
if(M==106845)puts("qwq");
  }
  return 0;
}

詳細信息

Test #1:

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

input:

4 2
1 2 3 4

output:

6.191147129557

result:

ok found '6.191147130', expected '6.191147130', error '0.000000000'

Test #2:

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

input:

10 3
1 2 3 4 5 6 7 8 9 10

output:

22.591625366514

result:

ok found '22.591625367', expected '22.591625367', error '0.000000000'

Test #3:

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

input:

1 1
1

output:

1.000000000000

result:

ok found '1.000000000', expected '1.000000000', error '0.000000000'

Test #4:

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

input:

1 1
100000

output:

316.227766016847

result:

ok found '316.227766017', expected '316.227766017', error '0.000000000'

Test #5:

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

input:

7 1
10 47 53 9 83 33 15

output:

41.833001326711

result:

ok found '41.833001327', expected '41.833001327', error '0.000000000'

Test #6:

score: 0
Accepted
time: 1ms
memory: 3940kb

input:

8 5
138 1702 119 1931 418 1170 840 1794

output:

233.901654551944

result:

ok found '233.901654552', expected '233.901654552', error '0.000000000'

Test #7:

score: 0
Accepted
time: 1ms
memory: 4140kb

input:

58 1
888 251 792 847 685 3 182 461 102 348 555 956 771 901 712 878 580 631 342 333 285 899 525 725 537 718 929 653 84 788 104 355 624 803 253 853 201 995 536 184 65 205 540 652 549 777 248 405 677 950 431 580 600 846 328 429 134 983

output:

1355.265287683578

result:

ok found '1355.265287684', expected '1355.265287684', error '0.000000000'

Test #8:

score: 0
Accepted
time: 1ms
memory: 4148kb

input:

88 30
67117 31903 93080 85196 16438 97116 11907 72959 83651 41273 52873 81892 81468 51323 99992 58869 54258 7183 87358 90990 80596 41252 90769 82705 61434 8524 13575 10787 53950 96768 12062 34637 27806 70937 69653 28380 90236 3352 27537 3873 91006 89790 25369 91825 82734 5588 4539 74118 47098 84741 ...

output:

18791.475354094100

result:

ok found '18791.475354094', expected '18791.475354094', error '0.000000000'

Test #9:

score: 0
Accepted
time: 3ms
memory: 4196kb

input:

987 59
5209 1618 7129 7700 893 6647 8231 3314 9844 1347 6789 2711 3968 7416 5864 9190 9564 8874 7357 2087 530 8754 7935 6772 3475 8206 2898 2717 9252 8686 6604 5188 7451 9977 9366 7618 6294 6454 3919 3232 8164 8403 8617 2191 5257 626 8554 1952 1727 4759 205 9453 3312 9387 4798 7774 7005 8892 3570 50...

output:

66075.508587054647

result:

ok found '66075.508587055', expected '66075.508587055', error '0.000000000'

Test #10:

score: 0
Accepted
time: 2ms
memory: 3904kb

input:

572 529
48392 84311 16267 29255 52276 20511 75195 95522 64489 52229 74478 69766 41777 25148 59976 66512 62953 16779 69312 98832 96131 94700 46403 58028 12868 83503 80367 51036 63398 7509 55193 76715 29143 75925 89863 89244 5561 21242 9047 89763 78016 86274 11382 88520 72343 29729 70986 86600 43707 7...

output:

119849.322681758061

result:

ok found '119849.322681758', expected '119849.322681758', error '0.000000000'

Test #11:

score: 0
Accepted
time: 13ms
memory: 4084kb

input:

6133 2231
2292 4026 3420 3246 5243 41 4223 468 682 5008 1497 584 1573 7049 5848 4129 5555 9957 9311 7225 6065 9498 3569 1695 717 1968 9690 7557 8700 9427 5142 371 8788 2260 9576 2674 4322 7448 5829 9123 982 7591 438 1590 9459 5982 5002 243 4144 4254 9585 9988 6745 3691 9602 2297 9518 1181 9814 1746 ...

output:

406852.366900471622

result:

ok found '406852.366900472', expected '406852.366900471', error '0.000000000'

Test #12:

score: 0
Accepted
time: 21ms
memory: 4276kb

input:

8384 5123
19058 18998 87373 34122 75328 47694 7628 72373 15038 82392 99284 70202 49919 24589 3369 42325 8281 56682 20694 78018 67433 34318 26086 37124 18668 94430 78732 53794 58279 21730 60156 95172 58849 10021 70991 26522 88420 92248 63779 33077 16703 80111 94041 85804 3110 21282 12757 69593 53872 ...

output:

1764954.761128222277

result:

ok found '1764954.761128222', expected '1764954.761128677', error '0.000000000'

Test #13:

score: 0
Accepted
time: 248ms
memory: 8292kb

input:

92842 83212
71466 9482 98728 78471 22915 2470 5999 53211 25994 3996 11349 30511 56448 17277 78308 18316 42069 38636 63127 26256 63985 57249 58305 64366 17839 28518 18980 95945 36316 6076 69530 96509 6940 6039 56048 41847 82118 41054 49670 95896 45891 74636 90736 75413 27251 87730 68344 66202 71879 5...

output:

19558873.688870181579

result:

ok found '19558873.688870180', expected '19558873.688863300', error '0.000000000'

Test #14:

score: 0
Accepted
time: 218ms
memory: 8532kb

input:

93773 73078
12212 18977 10701 17909 16643 1406 15608 19767 11321 4708 10418 5834 10141 18240 12668 2694 11528 16150 8201 793 9736 15133 17474 6052 830 8574 1473 6393 11680 9784 16406 3428 10520 6431 7941 3167 17474 16569 19046 9595 7858 12512 7204 414 13548 7490 9887 9184 4298 1124 8330 749 12122 14...

output:

8833985.139924723863

result:

ok found '8833985.139924724', expected '8833985.139919622', error '0.000000000'

Test #15:

score: 0
Accepted
time: 258ms
memory: 8552kb

input:

93116 27259
19231 23827 31564 18589 37658 17067 9191 26550 24206 13382 31064 1668 35186 10253 21408 16584 23217 11706 6324 16856 1642 28253 25916 39965 9455 35610 19925 15446 23558 36649 20624 35732 32683 33877 35121 26492 33868 35902 3312 18504 12747 31575 827 16198 22080 8616 16114 11479 1973 3457...

output:

12413208.327070225343

result:

ok found '12413208.327070225', expected '12413208.327073758', error '0.000000000'

Test #16:

score: 0
Accepted
time: 227ms
memory: 6844kb

input:

65921 2855
20842 45572 19723 30757 45969 18135 30070 21845 37090 9353 43198 30206 34823 2265 17444 873 3418 23069 21343 37110 34764 57182 14358 46583 33887 35351 2569 23283 58540 16218 14441 20740 19039 38219 56892 41305 10261 59427 50682 24309 37637 26446 14450 19278 6420 9741 22342 33775 32351 802...

output:

10762858.112821446913

result:

ok found '10762858.112821447', expected '10762858.112821424', error '0.000000000'

Test #17:

score: 0
Accepted
time: 142ms
memory: 6184kb

input:

51522 31326
39349 67318 23689 58733 39687 26500 10949 48629 17271 5323 48036 50232 34460 66982 78888 57867 15107 34433 12169 33173 75182 30302 50097 36305 18320 75092 65214 79632 63123 75786 38659 5749 68498 18369 24071 64631 59359 18760 27652 45922 69822 61317 75369 39254 14952 10867 37081 64582 55...

output:

9723573.246029383465

result:

ok found '9723573.246029383', expected '9723573.246029738', error '0.000000000'

Test #18:

score: 0
Accepted
time: 153ms
memory: 6508kb

input:

56053 42277
44411 63391 89865 72721 53843 682 14093 38372 3169 41756 82551 28149 31782 71836 19611 34812 18856 72210 69678 67556 59039 36318 44318 35358 85736 5362 64440 45710 1222 39219 67664 73453 3228 55740 31308 7845 75460 36874 46537 50376 58011 3889 4885 83498 25570 821 87491 47826 2719 12994 ...

output:

11198792.698454929304

result:

ok found '11198792.698454930', expected '11198792.698453829', error '0.000000000'

Test #19:

score: 0
Accepted
time: 28ms
memory: 4200kb

input:

10687 1668
3046 53154 91555 70369 35072 15080 9869 99592 62955 62818 3738 33628 46863 21042 26955 49834 6856 3243 6710 72239 24998 91735 93252 56350 61643 4017 22164 55902 95984 89163 14423 82410 24767 26122 89106 92303 22874 50437 24863 12593 40947 70729 13996 31622 46354 1272 78874 62489 56915 511...

output:

2255523.482818719013

result:

ok found '2255523.482818719', expected '2255523.482818719', error '0.000000000'

Test #20:

score: 0
Accepted
time: 46ms
memory: 4196kb

input:

18491 14176
87034 87309 95737 63513 94815 15170 3598 37211 10872 34733 51296 31647 86912 8982 7437 57343 48536 17100 16918 66460 49859 6047 93123 42873 47721 46308 98300 90715 23288 91189 11794 36943 49470 66414 74516 58084 90033 84433 85946 26700 65191 4451 75166 44736 98110 91661 86206 22681 16853...

output:

3888512.059149803498

result:

ok found '3888512.059149804', expected '3888512.059150661', error '0.000000000'

Test #21:

score: 0
Accepted
time: 107ms
memory: 4996kb

input:

34254 8157
71022 54169 99920 91248 54559 47964 38544 7534 82981 82455 55750 29665 83857 5435 22510 64853 22919 30957 59830 27977 66208 53064 92993 86291 25288 31704 41733 17016 60992 58623 41868 56885 15389 82515 68439 32377 24487 42622 3926 6216 24027 95069 95121 57849 84458 71650 52322 15577 44088...

output:

7195750.042143236772

result:

ok found '7195750.042143237', expected '7195750.042144855', error '0.000000000'

Test #22:

score: 0
Accepted
time: 133ms
memory: 5712kb

input:

48030 28734
87714 88324 4102 84392 81599 48055 32273 2049 30898 30178 3309 60387 23906 69184 46096 15466 64598 10222 70039 22199 23772 10480 92863 5517 35558 41291 17869 19125 55592 93353 71943 44122 72795 22808 53849 30862 83133 811 65010 96131 48271 85687 23588 70963 60406 18935 59655 8473 4026 43...

output:

10117497.098384469533

result:

ok found '10117497.098384470', expected '10117497.098384907', error '0.000000000'

Test #23:

score: 0
Accepted
time: 140ms
memory: 5872kb

input:

45116 12480
38998 22480 8284 44832 17150 48145 34514 72372 78815 2092 7763 58405 20850 57124 93874 22975 38981 24079 88759 16420 48633 24792 68541 81639 54341 16286 61301 53937 58704 28082 2018 31360 62906 71613 71964 63939 50292 34807 58797 75647 72515 43601 76246 84077 79457 42028 58475 68665 3126...

output:

9528295.640644061691

result:

ok found '9528295.640644062', expected '9528295.640645649', error '0.000000000'

Test #24:

score: 0
Accepted
time: 183ms
memory: 6216kb

input:

56563 5852
22986 89339 12467 5271 44190 56747 28243 66887 59436 15223 55321 13319 85091 20873 41651 30485 4852 37936 98967 77937 97686 82209 35708 68161 31907 25873 37438 56046 20600 95516 32093 18597 96121 11906 65886 38232 84746 92996 19881 89755 31351 34219 4713 97191 98509 89314 33103 61561 5849...

output:

11918743.606859443988

result:

ok found '11918743.606859444', expected '11918743.606859455', error '0.000000000'

Test #25:

score: 0
Accepted
time: 136ms
memory: 5624kb

input:

40604 4266
6974 56198 16649 98415 36638 56837 30485 37210 7353 87137 27071 44041 57844 17325 22133 70698 79236 84497 41879 72158 22547 29225 35578 87387 17985 43972 80870 15051 91009 97542 29464 5835 53527 28006 51297 36717 19201 51185 80964 36566 55595 67941 57372 86112 41753 12407 31924 54457 1843...

output:

8546423.377446428580

result:

ok found '8546423.377446428', expected '8546423.377446430', error '0.000000000'

Test #26:

score: 0
Accepted
time: 144ms
memory: 6500kb

input:

55318 38425
90962 90354 20831 58854 63677 24224 24214 31725 79463 34859 7333 42059 54789 81074 45719 54015 53619 98354 27896 99083 47408 19345 35448 30805 28256 53559 24302 17160 85609 64976 59539 68881 10934 68299 69411 2498 86359 85182 66240 83378 79839 58559 85839 31930 60805 59692 30744 23161 21...

output:

11659354.108219661525

result:

ok found '11659354.108219661', expected '11659354.108220546', error '0.000000000'

Test #27:

score: 0
Accepted
time: 407ms
memory: 14036kb

input:

200000 1234
15 714 103 881 808 595 505 281 451 187 555 889 276 415 335 227 613 937 149 954 82 632 855 765 134 134 245 675 83 168 955 785 143 290 750 373 25 504 115 47 368 550 792 522 356 745 337 120 91 388 284 283 198 260 181 565 145 708 91 673 86 26 89 463 683 328 798 692 39 660 213 263 697 232 270...

output:

4214040.176869952842

result:

ok found '4214040.176869953', expected '4214040.176869883', error '0.000000000'

Test #28:

score: 0
Accepted
time: 357ms
memory: 14124kb

input:

200000 199999
10 7 5 1 4 3 5 2 1 9 4 2 8 9 4 2 1 1 10 4 5 3 10 9 2 10 5 7 3 8 10 2 7 8 3 2 2 8 4 6 3 5 6 4 1 3 6 8 10 5 10 6 3 9 7 7 5 2 5 5 8 10 8 8 10 3 3 3 2 8 8 8 7 4 6 7 6 4 4 8 7 10 7 5 7 8 7 9 10 9 3 4 7 2 6 7 3 4 8 1 10 8 10 10 9 7 7 7 9 3 6 5 5 2 9 7 5 9 10 6 2 5 8 5 8 6 8 3 9 4 3 2 1 9 9 4...

output:

449053.811111192317

result:

ok found '449053.811111192', expected '449053.811111193', error '0.000000000'

Test #29:

score: 0
Accepted
time: 416ms
memory: 14016kb

input:

200000 200000
358 771 657 465 176 649 647 448 728 699 177 933 260 526 992 470 894 953 535 67 749 6 152 49 442 532 917 115 820 799 320 684 604 446 507 966 177 845 665 390 798 17 484 245 343 678 420 385 400 372 302 986 94 174 714 69 715 498 189 245 22 555 789 581 313 218 792 327 601 353 365 568 666 63...

output:

4222121.930009042732

result:

ok found '4222121.930009043', expected '4222121.930008642', error '0.000000000'

Test #30:

score: 0
Accepted
time: 523ms
memory: 14000kb

input:

200000 200000
87338 73783 5523 51991 2881 68863 41883 44070 3441 34634 95748 88273 74444 60113 20629 22994 13258 95825 61397 99590 61030 26857 37043 41169 72575 53085 65727 47415 21721 75830 69038 55268 50746 56928 98969 81861 17837 48843 62334 78509 75970 45483 74046 80593 36396 24888 86046 76524 9...

output:

42177852.877744565711

result:

ok found '42177852.877744563', expected '42177852.877710223', error '0.000000000'

Test #31:

score: 0
Accepted
time: 667ms
memory: 14272kb

input:

200000 5698
82273 82167 30031 13695 19452 64050 68613 897 334 80715 14998 44711 28499 78542 13914 76158 78533 3286 14277 58166 81541 45757 14133 58390 60765 90835 10826 28045 71726 17165 9760 34757 97720 82390 89908 25061 40905 72791 45647 36498 34106 74512 22859 78545 83357 59834 44256 89374 25931 ...

output:

42175982.597805788762

result:

ok found '42175982.597805791', expected '42175982.597805873', error '0.000000000'

Test #32:

score: 0
Accepted
time: 363ms
memory: 14232kb

input:

200000 57033
49 95 72 8 70 13 12 59 1 39 53 79 49 64 46 94 13 30 54 69 98 2 39 7 87 4 91 12 88 10 6 15 32 95 22 66 63 18 94 1 33 25 89 6 52 58 91 40 68 53 49 58 38 37 83 78 8 19 5 53 53 26 12 4 76 85 78 16 92 42 46 64 74 24 42 77 53 11 28 82 95 47 94 82 62 47 38 66 64 60 12 28 25 3 23 60 84 8 75 87 ...

output:

32283131.201387174957

result:

ok found '32283131.201387174', expected '32283131.201386724', error '0.000000000'

Test #33:

score: 0
Accepted
time: 369ms
memory: 14124kb

input:

200000 192622
22 77 88 52 25 20 83 18 76 47 84 34 54 88 9 90 49 8 79 91 78 51 56 57 13 7 35 45 71 99 25 42 92 84 2 66 46 19 95 77 87 85 90 59 90 38 89 10 23 35 78 25 12 4 74 35 44 18 31 5 28 45 55 31 63 90 46 93 48 65 40 90 72 45 71 82 76 95 52 53 22 78 79 77 99 43 8 38 35 41 8 57 85 35 96 24 11 64 ...

output:

32283316.334659658309

result:

ok found '32283316.334659658', expected '32283316.334659215', error '0.000000000'

Test #34:

score: 0
Accepted
time: 366ms
memory: 14236kb

input:

200000 142088
88 24 73 53 86 93 28 44 44 13 84 36 9 30 70 80 80 45 51 97 14 85 16 21 24 60 88 78 56 60 39 23 33 7 60 93 32 85 97 34 4 35 10 66 92 29 64 31 53 35 88 74 40 60 73 82 90 1 43 87 6 67 83 35 89 95 47 14 20 15 11 24 27 82 24 59 42 74 96 50 73 61 26 79 13 59 29 21 4 70 49 42 79 81 67 18 15 4...

output:

32284074.532722138532

result:

ok found '32284074.532722138', expected '32284074.532721698', error '0.000000000'

Test #35:

score: 0
Accepted
time: 357ms
memory: 14236kb

input:

200000 120274
25 80 33 47 43 55 92 10 3 85 41 52 58 37 12 80 50 67 14 48 50 9 95 67 67 12 93 63 34 27 93 73 68 27 56 83 94 59 7 78 42 46 29 74 6 98 80 86 52 71 27 97 56 10 48 80 74 23 32 81 28 25 96 95 35 77 84 76 77 97 96 97 95 78 83 48 74 23 1 58 85 61 13 63 31 98 18 67 45 78 19 20 86 33 56 72 3 1...

output:

32281919.891219260777

result:

ok found '32281919.891219262', expected '32281919.891218837', error '0.000000000'

Test #36:

score: -100
Wrong Answer
time: 367ms
memory: 14096kb

input:

200000 106845
73 1 24 86 79 77 90 78 11 2 25 67 63 77 74 79 37 69 90 4 85 8 28 11 81 6 92 6 52 14 86 76 32 64 71 77 88 53 52 12 91 76 67 38 71 32 34 12 34 23 60 3 98 5 97 21 96 9 45 22 28 87 29 21 12 32 2 17 6 43 87 19 51 51 74 61 82 40 38 84 62 39 81 9 18 69 53 16 50 87 23 46 47 69 91 93 38 93 39 7...

output:

32283102.290457790205
qwq

result:

wrong output format Extra information in the output file