結果

問題 No.2698 Many Asakatsu
ユーザー 👑 emthrmemthrm
提出日時 2024-03-22 23:13:24
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,792 bytes
コンパイル時間 2,864 ms
コンパイル使用メモリ 247,752 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-03-22 23:13:39
合計ジャッジ時間 12,451 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 2 ms
6,548 KB
testcase_04 AC 2 ms
6,548 KB
testcase_05 AC 2 ms
6,548 KB
testcase_06 AC 2 ms
6,548 KB
testcase_07 AC 2 ms
6,548 KB
testcase_08 AC 2 ms
6,548 KB
testcase_09 AC 2 ms
6,548 KB
testcase_10 AC 3 ms
6,548 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 4 ms
6,548 KB
testcase_14 AC 8 ms
6,548 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 11 ms
6,548 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 435 ms
6,548 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 603 ms
6,548 KB
testcase_31 WA -
testcase_32 AC 439 ms
6,548 KB
testcase_33 AC 424 ms
6,548 KB
testcase_34 AC 704 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 998244353;
// constexpr int MOD = 1000000007;
constexpr int DY4[]{1, 0, -1, 0}, DX4[]{0, -1, 0, 1};
constexpr int DY8[]{1, 1, 0, -1, -1, -1, 0, 1};
constexpr int DX8[]{0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U>
inline bool chmax(T& a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U>
inline bool chmin(T& a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);
  }
} iosetup;

ll aripro(const int a, const int d, const int n) {
  return n * (a * 2 + (n - 1LL) * d) / 2;
}

ll d(const int a, const int b, const int m, const ll r) {
  if (a > r) return aripro(a, b, m) - r * m;
  int lb = 0, ub = m;
  while (ub - lb > 1) {
    const int mid = midpoint(lb, ub);
    (a + ll{b} * mid <= r ? lb : ub) = mid;
  }
  return r * (lb + 1) - aripro(a, b, lb + 1) + aripro(a + b * (lb + 1LL), b, m - (lb + 1)) - r * (m - (lb + 1));
}

int main() {
  int n, m; cin >> n >> m;
  vector<int> a(n), b(n); REP(i, n) cin >> a[i] >> b[i];
  int q; ll x; cin >> q >> x;
  vector<int> c(n);
  for (int& c_i : c) cin >> c_i;
  int i = 0;
  REP(tm, q) {
    while (i + 1 < n && d(a[i], b[i], m, x) > d(a[i + 1], b[i + 1], m, x)) ++i;
    ll diff = LINF;
    int ans = -1;
    FOR(j, max(i - 10, 0), min(i + 11, n)) {
      if (chmin(diff, d(a[j], b[j], m, x))) ans = j;
    }
    cout << ans + 1 << " \n"[tm + 1 == q];
    x += c[ans];
  }
  return 0;
}
0