Submission #4268644


Source Code Expand

Copy
#include<bits/stdc++.h>

using namespace std;

using int64 = long long;
const int INF = 1 << 30;

int main() {
  int64 N, L, X[300000], Y[300000], T[300000];
  cin >> N >> L;
  for(int i = 0; i < N; i++) {
    cin >> X[i];
    Y[i] = L - X[i];
  }
  for(int i = 0; i < N; i++) {
    cin >> T[i];
  }


  int64 t[100000][2];

  int64 pre = 1, just = 0;
  vector< int > idx;
  for(int i = 0; i < N; i++) {
    pre += T[i] / (2 * L);
    T[i] %= 2 * L;
    if(T[i] == 0) {
    } else {
      bool latte = T[i] <= Y[i] * 2; // o---->   o<----
      bool malta = T[i] <= X[i] * 2; // <----o   ---->o
      t[i][0] = latte;
      t[i][1] = malta;
      idx.emplace_back(i);
      if(!latte && !malta) ++pre;
      else ++just;
    }
  }
  int tap = -INF;
  auto check = [&](int times) {
    int front = 0, ret = 0;
    for(int i : idx) {
      int z = false;
      if(!t[i][0] && !t[i][1]) {
        continue;
      } else if(t[i][0] && t[i][1]) {
        if(times > 0) {
          --times;
          z = true;
        }
      } else if(t[i][1]) {
        z = true;
      }
      if(z) {
        ++front;
      } else {
        if(front > 0 || i == idx.back()) {
          ++ret;
          --front;
        }
      }
    }
    tap = max(tap, ret);
    return ret;
  };
  int ok = 0, ng = INF;
  while(ng - ok > 1) {
    int mid = (ok + ng) / 2;
    if(check(mid) < check(mid + 1)) ok = mid;
    else ng = mid;
  }
  cout << (pre + just - tap) * 2 * L << endl;
}

Submission Info

Submission Time
Task D - Shopping
User ei13333
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1528 Byte
Status
Exec Time 328 ms
Memory 10996 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 s1.txt, s2.txt, s3.txt, s4.txt
Partial 0 / 1000 s1.txt, s2.txt, s3.txt, s4.txt, sub1_01.txt, sub1_02.txt, sub1_03.txt, sub1_04.txt, sub1_05.txt, sub1_06.txt, sub1_07.txt, sub1_08.txt, sub1_09.txt, sub1_10.txt, sub1_11.txt, sub1_12.txt, sub1_13.txt, sub1_14.txt, sub1_15.txt, sub1_16.txt, sub1_17.txt, sub1_18.txt, sub1_19.txt, sub1_20.txt, sub1_21.txt, sub1_22.txt, sub1_23.txt, sub1_24.txt, sub1_25.txt, sub1_26.txt, sub1_27.txt, sub1_28.txt, sub1_29.txt, sub1_30.txt, sub1_31.txt, sub1_32.txt, sub1_33.txt, sub1_34.txt, sub1_35.txt, sub1_36.txt, sub1_37.txt, sub1_38.txt, sub1_39.txt, sub1_40.txt, sub1_41.txt, sub1_42.txt, sub1_43.txt, sub1_44.txt, sub1_45.txt, sub1_46.txt, sub1_47.txt, sub1_48.txt
All 0 / 600 49.txt, 50.txt, 51.txt, 52.txt, 53.txt, 54.txt, 55.txt, 56.txt, 57.txt, 58.txt, 59.txt, 60.txt, 61.txt, 62.txt, 63.txt, 64.txt, 65.txt, 66.txt, 67.txt, 68.txt, 69.txt, 70.txt, 71.txt, 72.txt, 73.txt, 74.txt, 75.txt, 76.txt, 77.txt, 78.txt, 79.txt, 80.txt, 81.txt, 82.txt, 83.txt, 84.txt, 85.txt, 86.txt, 87.txt, 88.txt, 89.txt, 90.txt, 91.txt, 92.txt, 93.txt, 94.txt, s1.txt, s2.txt, s3.txt, s4.txt, sub1_01.txt, sub1_02.txt, sub1_03.txt, sub1_04.txt, sub1_05.txt, sub1_06.txt, sub1_07.txt, sub1_08.txt, sub1_09.txt, sub1_10.txt, sub1_11.txt, sub1_12.txt, sub1_13.txt, sub1_14.txt, sub1_15.txt, sub1_16.txt, sub1_17.txt, sub1_18.txt, sub1_19.txt, sub1_20.txt, sub1_21.txt, sub1_22.txt, sub1_23.txt, sub1_24.txt, sub1_25.txt, sub1_26.txt, sub1_27.txt, sub1_28.txt, sub1_29.txt, sub1_30.txt, sub1_31.txt, sub1_32.txt, sub1_33.txt, sub1_34.txt, sub1_35.txt, sub1_36.txt, sub1_37.txt, sub1_38.txt, sub1_39.txt, sub1_40.txt, sub1_41.txt, sub1_42.txt, sub1_43.txt, sub1_44.txt, sub1_45.txt, sub1_46.txt, sub1_47.txt, sub1_48.txt
Case Name Status Exec Time Memory
49.txt 186 ms 9336 KB
50.txt 250 ms 10996 KB
51.txt 26 ms 6912 KB
52.txt 318 ms 10996 KB
53.txt 200 ms 9080 KB
54.txt 318 ms 10996 KB
55.txt 10 ms 6656 KB
56.txt 214 ms 10996 KB
57.txt 169 ms 9592 KB
58.txt 213 ms 10996 KB
59.txt 149 ms 9592 KB
60.txt 213 ms 10996 KB
61.txt 9 ms 6656 KB
62.txt 213 ms 10996 KB
63.txt 217 ms 9848 KB
64.txt 235 ms 9976 KB
65.txt 11 ms 6656 KB
66.txt 236 ms 9976 KB
67.txt 257 ms 9592 KB
68.txt 295 ms 9976 KB
69.txt 218 ms 9336 KB
70.txt 296 ms 9976 KB
71.txt 10 ms 6656 KB
72.txt 235 ms 10996 KB
73.txt 217 ms 10868 KB
74.txt 236 ms 10996 KB
75.txt 12 ms 6656 KB
76.txt 282 ms 10996 KB
77.txt 227 ms 9848 KB
78.txt 281 ms 10996 KB
79.txt 211 ms 9336 KB
80.txt 296 ms 9976 KB
81.txt 11 ms 6656 KB
82.txt 297 ms 9976 KB
83.txt 195 ms 10996 KB
84.txt 213 ms 10996 KB
85.txt 126 ms 9336 KB
86.txt 214 ms 10996 KB
87.txt 202 ms 10868 KB
88.txt 214 ms 10996 KB
89.txt 56 ms 9468 KB
90.txt 213 ms 10996 KB
91.txt 52 ms 7548 KB
92.txt 312 ms 9976 KB
93.txt 164 ms 8952 KB
94.txt 328 ms 10996 KB
s1.txt 2 ms 6400 KB
s2.txt 3 ms 6400 KB
s3.txt 3 ms 6400 KB
s4.txt 3 ms 6400 KB
sub1_01.txt 3 ms 6400 KB
sub1_02.txt 2 ms 4352 KB
sub1_03.txt 4 ms 6400 KB
sub1_04.txt 5 ms 6528 KB
sub1_05.txt 4 ms 6400 KB
sub1_06.txt 5 ms 4480 KB
sub1_07.txt 4 ms 6400 KB
sub1_08.txt 6 ms 6528 KB
sub1_09.txt 4 ms 6400 KB
sub1_10.txt 4 ms 6528 KB
sub1_11.txt 4 ms 6400 KB
sub1_12.txt 4 ms 6528 KB
sub1_13.txt 4 ms 6528 KB
sub1_14.txt 4 ms 6528 KB
sub1_15.txt 4 ms 4480 KB
sub1_16.txt 4 ms 6528 KB
sub1_17.txt 3 ms 6400 KB
sub1_18.txt 5 ms 6400 KB
sub1_19.txt 5 ms 6400 KB
sub1_20.txt 5 ms 6400 KB
sub1_21.txt 5 ms 8448 KB
sub1_22.txt 5 ms 6528 KB
sub1_23.txt 3 ms 6400 KB
sub1_24.txt 5 ms 6528 KB
sub1_25.txt 3 ms 6400 KB
sub1_26.txt 4 ms 4480 KB
sub1_27.txt 3 ms 4352 KB
sub1_28.txt 5 ms 6528 KB
sub1_29.txt 3 ms 6400 KB
sub1_30.txt 5 ms 6528 KB
sub1_31.txt 4 ms 6400 KB
sub1_32.txt 5 ms 6528 KB
sub1_33.txt 4 ms 4352 KB
sub1_34.txt 5 ms 6528 KB
sub1_35.txt 4 ms 4480 KB
sub1_36.txt 5 ms 4480 KB
sub1_37.txt 4 ms 6528 KB
sub1_38.txt 4 ms 6528 KB
sub1_39.txt 3 ms 6400 KB
sub1_40.txt 4 ms 6528 KB
sub1_41.txt 3 ms 6400 KB
sub1_42.txt 4 ms 6528 KB
sub1_43.txt 3 ms 4352 KB
sub1_44.txt 4 ms 6528 KB
sub1_45.txt 4 ms 6400 KB
sub1_46.txt 5 ms 6528 KB
sub1_47.txt 4 ms 6400 KB
sub1_48.txt 5 ms 6528 KB