結果
| 問題 | No.3288 Sloppy Land Grading | 
| コンテスト | |
| ユーザー |  tnakao0123 | 
| 提出日時 | 2025-10-04 19:30:38 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 85 ms / 2,000 ms | 
| コード長 | 1,063 bytes | 
| コンパイル時間 | 361 ms | 
| コンパイル使用メモリ | 42,964 KB | 
| 実行使用メモリ | 7,716 KB | 
| 最終ジャッジ日時 | 2025-10-04 19:30:41 | 
| 合計ジャッジ時間 | 2,879 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 16 | 
コンパイルメッセージ
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);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            
            ソースコード
/* -*- 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;
}
            
            
            
        