QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#313466#5264. Wyprzedzaniezfs73230 66ms37928kbC++142.6kb2024-01-24 19:36:052024-01-24 19:36:06

Judging History

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

  • [2024-01-24 19:36:06]
  • 评测
  • 测评结果:30
  • 用时:66ms
  • 内存:37928kb
  • [2024-01-24 19:36:05]
  • 提交

answer

/*
 * _|_|_|_|_|  _|_|_|_|    _|_|_|  _|_|_|_|_|  _|_|_|      _|_|
 *       _|    _|        _|                _|        _|  _|    _|
 *     _|      _|_|_|      _|_|          _|      _|_|        _|
 *   _|        _|              _|      _|            _|    _|
 * _|_|_|_|_|  _|        _|_|_|      _|        _|_|_|    _|_|_|_|
 */

#include<bits/stdc++.h>

const int maxN = 1e5 + 1, maxM = 17;

const long double eps = 1e-8;

long double f[maxM][maxN];
long double ct[maxN], s[maxN], d[maxN], sd[maxN], v[maxN];

inline long double GetV() {
  long double x, y;
  return std::cin >> x >> y, x / y;
}

inline long double Query(int l, int r) {
  if (r < l)
    return 0;

  int k = std::__lg(r - l + 1);
  return std::max(f[k][l], f[k][r - (1 << k) + 1]);
}

int main() {
#ifdef LOCAL
  freopen("task.in", "r", stdin);
  freopen("task.out", "w", stdout);
  freopen("task.err", "w", stderr);
#endif
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int n, ans = 1;
  long double D, V;
  std::cin >> n >> D, V = GetV();

  for (int i = 1; i <= n; i++) {
    std::cin >> s[i] >> d[i];
    sd[i] = sd[i - 1] + d[i];
    v[i] = GetV();
  }

  std::vector<int> sta;
  sta.emplace_back(n);
  f[0][n] = ct[n] = 1e20;

  auto Catch = [&](int x, int i) {
    long double diff = (s[x] - s[i]) - (sd[x] - sd[i]);
    return diff / (v[i] - v[x]);
  };

  for (int i = n - 1; i >= 1; i--) {
    auto Check = [&](int x) {
      long double t1 = Query(i + 1, x - 1);
      long double t2 = Catch(x, i);
      return t2 - t1 > -eps;
    };

    while (!sta.empty() && v[sta.back()] - v[i] > -eps)
      sta.pop_back();

    if (!sta.empty()) {
      int l = 0, r = int(sta.size() - 1);

      while (l < r) {
        int mid = (l + r) >> 1;

        if (Check(sta[mid]))
          r = mid;
        else
          l = mid + 1;
      }

      ct[i] = Catch(sta[l], i);
    } else
      ct[i] = 1e20;

    f[0][i] = ct[i];
    sta.emplace_back(i);

    for (int j = 1; i + (1 << j) - 1 <= n; j++)
      f[j][i] = std::max(f[j - 1][i], f[j - 1][i + (1 << (j - 1))]);
  }

  for (int i = 1; i < n; i++) {
    long double t = (D + s[i]) / (V - v[i]);

    if (ct[i] <= t)
      continue;

    int l = i + 1, r = n;

    while (l < r) {
      int mid = (l + r + 1) >> 1;

      if (t - Query(i + 1, mid - 1) > -eps)
        l = mid;
      else
        r = mid - 1;
    }

    long double pos = s[l] + t * v[l] - (sd[l] - sd[i]);
    long double diff = pos - (t * v[i] + s[i]);
    ans += diff - D > -eps;
  }

  std::cout << ans << '\n';

  return 0;
}

詳細信息

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 54ms
memory: 37844kb

input:

100000 9 445 874
1653 9 34 792
2736 336 34 792
21599 862 34 792
23975 188 34 792
41891 401 34 792
62576 193 34 792
74285 567 34 792
78959 2850 34 792
85316 452 34 792
92188 217 34 792
97244 3526 34 792
106804 599 34 792
112500 1352 34 792
120610 581 34 792
123644 213 34 792
123754 16 34 792
125589 4...

output:

99905

result:

ok single line: '99905'

Test #2:

score: 0
Accepted
time: 51ms
memory: 36764kb

input:

100000 42 423 459
37434 62 373 551
55489 515 373 551
58121 1271 373 551
62626 1237 373 551
85240 1500 373 551
100367 2450 373 551
103859 766 373 551
105195 647 373 551
113654 79 373 551
116413 2078 373 551
123362 157 373 551
128320 670 373 551
130075 1030 373 551
146426 397 373 551
155828 1195 373 5...

output:

99539

result:

ok single line: '99539'

Test #3:

score: 0
Accepted
time: 58ms
memory: 37564kb

input:

100000 514 651 267
5878 637 349 559
8958 1820 349 559
19500 1747 349 559
26299 1243 349 559
27584 995 349 559
30038 128 349 559
41755 367 349 559
46773 28 349 559
57112 3790 349 559
77098 1945 349 559
79912 346 349 559
81176 1071 349 559
96565 1741 349 559
99869 1267 349 559
105062 1131 349 559
1225...

output:

94212

result:

ok single line: '94212'

Test #4:

score: 0
Accepted
time: 58ms
memory: 36720kb

input:

100000 6903 385 122
27659 90 660 238
29771 3 660 238
33082 45 660 238
36254 55 660 238
37436 36 660 238
49934 126 660 238
56662 21 660 238
64037 20 660 238
70132 223 660 238
73123 37 660 238
74391 106 660 238
87544 26 660 238
90127 179 660 238
95773 66 660 238
108314 4 660 238
111360 113 660 238
115...

output:

49159

result:

ok single line: '49159'

Test #5:

score: 0
Accepted
time: 54ms
memory: 37572kb

input:

100000 47429 212 203
11292 49 249 293
19281 41 249 293
38517 20 249 293
65772 24 249 293
73342 63 249 293
86818 112 249 293
95250 201 249 293
98973 183 249 293
132629 18 249 293
138479 87 249 293
139269 40 249 293
140399 74 249 293
141852 100 249 293
157957 20 249 293
160317 24 249 293
160534 53 249...

output:

970

result:

ok single line: '970'

Test #6:

score: 0
Accepted
time: 54ms
memory: 37784kb

input:

100000 891884 617 488
5243 119 597 691
6747 15 597 691
14373 119 597 691
17883 52 597 691
20388 113 597 691
50660 73 597 691
58923 161 597 691
63414 61 597 691
76445 157 597 691
84324 38 597 691
88647 197 597 691
97447 498 597 691
106705 34 597 691
119011 122 597 691
150042 63 597 691
164835 102 597...

output:

2

result:

ok single line: '2'

Test #7:

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

input:

1 1000000000 761 455
1000000000 1 737 595

output:

1

result:

ok single line: '1'

Subtask #2:

score: 20
Accepted

Dependency #1:

100%
Accepted

Test #8:

score: 20
Accepted
time: 56ms
memory: 37156kb

input:

100000 9 984 1
13277 1519 1 998
50255 1248 1 991
76049 794 1 979
78294 128 1 978
84461 2332 1 969
117959 2101 1 943
138836 3303 1 932
139565 418 1 932
143805 216 1 928
150460 1323 1 928
153651 105 1 924
159235 175 1 898
165846 1922 1 891
174840 2016 1 886
184405 800 1 880
200807 711 1 878
210013 174...

output:

99963

result:

ok single line: '99963'

Test #9:

score: 0
Accepted
time: 59ms
memory: 37356kb

input:

100000 31 997 1
1041 5 1 998
14054 1061 1 982
20888 3270 1 970
40091 1054 1 940
44674 353 1 937
45648 271 1 931
48417 659 1 926
57508 1070 1 904
63225 55 1 900
66451 1733 1 898
68665 579 1 895
70696 1548 1 894
100516 530 1 883
103117 68 1 868
108640 723 1 862
113044 310 1 857
116930 421 1 857
120527...

output:

99800

result:

ok single line: '99800'

Test #10:

score: 0
Accepted
time: 55ms
memory: 37644kb

input:

100000 822 1000 1
2968 768 1 1000
21579 31 1 999
25773 1431 1 996
27447 1036 1 982
34954 255 1 982
50345 3194 1 967
59666 469 1 960
95568 2012 1 942
116776 4462 1 938
130891 1467 1 929
135657 148 1 893
137747 2 1 880
141581 2150 1 879
160529 225 1 872
170809 1500 1 872
171997 727 1 861
182071 189 1 ...

output:

91841

result:

ok single line: '91841'

Test #11:

score: 0
Accepted
time: 66ms
memory: 36756kb

input:

100000 5379 992 1
16416 11 1 997
20030 59 1 997
31208 298 1 994
35979 19 1 986
37550 80 1 981
54939 36 1 913
58490 123 1 913
62154 34 1 909
62613 20 1 862
68902 63 1 861
74561 18 1 846
82073 36 1 842
101997 112 1 842
109319 10 1 819
127017 44 1 810
132013 108 1 809
148866 11 1 804
183313 20 1 802
19...

output:

59408

result:

ok single line: '59408'

Test #12:

score: 0
Accepted
time: 57ms
memory: 36856kb

input:

100000 38590 1000 1
9503 122 1 994
9862 113 1 984
12816 72 1 951
18952 35 1 937
46312 281 1 931
59176 99 1 930
60739 30 1 928
66948 152 1 910
69161 62 1 894
74109 22 1 886
85758 114 1 881
106054 21 1 880
120363 81 1 877
134005 21 1 865
136631 39 1 864
147254 102 1 851
154084 73 1 850
158311 3 1 816
...

output:

3428

result:

ok single line: '3428'

Test #13:

score: 0
Accepted
time: 62ms
memory: 37928kb

input:

100000 990557 987 1
11760 171 1 995
13375 117 1 988
16115 232 1 983
48046 63 1 970
58961 121 1 940
62062 40 1 933
64806 3 1 909
92075 144 1 905
107413 27 1 902
109695 80 1 899
120050 37 1 895
140820 4 1 875
146407 7 1 874
155458 143 1 861
162536 104 1 857
171054 174 1 856
175081 69 1 841
176075 37 1...

output:

199

result:

ok single line: '199'

Test #14:

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

input:

1 1000000000 859 157
1000000000 1 583 629

output:

1

result:

ok single line: '1'

Subtask #3:

score: 0
Wrong Answer

Test #15:

score: 35
Accepted
time: 0ms
memory: 24212kb

input:

1000 5 716 3
632 108 255 785
1891 115 699 140
2143 130 778 315
3409 155 450 486
7330 57 351 675
10955 24 959 657
13151 127 37 429
13903 115 749 82
15213 37 267 276
15906 168 971 23
17068 74 751 600
18435 207 306 662
18493 4 463 490
18882 60 381 293
22184 64 888 663
27168 89 962 190
28751 121 122 898...

output:

527

result:

ok single line: '527'

Test #16:

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

input:

1000 20 917 8
1820 78 441 641
3590 90 486 512
6487 194 536 942
7056 123 266 270
8508 87 130 622
8990 30 654 463
10808 23 741 79
10932 27 228 776
11215 111 458 864
11778 38 751 153
12021 15 321 435
12053 9 162 741
12341 120 496 802
14246 23 431 808
16027 7 508 119
18356 168 362 909
20542 68 465 53
21...

output:

416

result:

ok single line: '416'

Test #17:

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

input:

1000 941 795 2
2446 276 652 673
3067 23 907 79
4023 57 20 189
4076 10 22 364
4263 46 101 752
4508 23 680 464
4777 178 638 58
5426 15 674 162
5537 43 75 564
5882 163 753 662
8162 125 142 638
9026 35 862 797
9117 57 689 398
11859 83 584 712
13277 17 897 881
13389 36 638 525
13790 20 763 810
16538 117 ...

output:

373

result:

ok single line: '373'

Test #18:

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

input:

1000 2625 10 1
477305 370 10 7
1151540 1000 7 10
1893809 12 9 1
3502666 718 4 6
3611320 296 6 6
5699350 260 3 8
8394591 596 3 10
8668961 750 2 4
11183997 981 8 7
13008836 37 10 8
14044159 2729 2 3
14287006 121 1 3
15373289 938 8 1
15724757 1165 1 4
16641191 1541 9 6
16980331 1060 7 3
17356572 4031 8...

output:

176

result:

ok single line: '176'

Test #19:

score: -35
Wrong Answer
time: 4ms
memory: 26424kb

input:

1000 95619 10 1
26818 358 5 2
1122928 1616 6 3
1716816 175 7 10
3119287 836 9 3
3421179 3539 5 8
3570557 357 8 3
3790272 927 3 3
4240818 1211 1 9
5172443 1049 4 9
6239353 52 9 3
6675674 1504 5 3
8167258 66 9 1
9517371 2632 4 9
10547195 527 4 5
11014094 143 3 7
11841288 402 7 4
11968651 1527 5 1
1257...

output:

179

result:

wrong answer 1st lines differ - expected: '178', found: '179'

Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

0%