結果

問題 No.3288 Sloppy Land Grading
ユーザー tnakao0123
提出日時 2025-10-04 19:28:15
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,064 bytes
コンパイル時間 430 ms
コンパイル使用メモリ 42,980 KB
実行使用メモリ 15,812 KB
最終ジャッジ日時 2025-10-04 19:28:20
合計ジャッジ時間 4,511 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other TLE * 1 -- * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:34:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   34 |   scanf("%d", &tn);
      |   ~~~~~^~~~~~~~~~~
main.cpp:38:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   38 |     scanf("%d%d%d%d%d%d", &a, &b, &c, &x, &y, &z);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 3288.cc:  No.3288 Sloppy Land Grading - yukicoder
 */

#include<cstdio>
#include<algorithm>

using namespace std;

/* constant */

const int MAX_N = 100000;
const long long LINF = 1LL << 62;

/* typedef */

using ll = long long;

/* global variables */

int as[MAX_N];

/* subroutines */

ll calc(int a, int b, int c, int x, int y, int z, int d) {
  return (ll)abs(a - d) * x + (ll)abs(b - d) * y + (ll)abs(c - d) * z;
}

/* main */

int main() {
  int tn;
  scanf("%d", &tn);

  while (tn--) {
    int a, b, c, x, y, z;
    scanf("%d%d%d%d%d%d", &a, &b, &c, &x, &y, &z);

    int d0 = min(min(a, b), c);
    int d1 = max(max(a, b), c);

    while (d0 + 2 <= d1) {
      int dd0 = (d0 * 2 + d1) / 3;
      int dd1 = (d0 + d1 * 2) / 3;
      ll s0 = calc(a, b, c, x, y, z, dd0);
      ll s1 = calc(a, b, c, x, y, z, dd1);
      if (s0 > s1) d0 = dd0;
      else d1 = dd1;
    }

    ll mins = LINF;
    for (int d = d0; d <= d1; d++)
      mins = min(mins, calc(a, b, c, x, y, z, d));

    printf("%lld\n", mins);
  }

  return 0;
}

0