結果

問題 No.3173 じゃんけんの勝ちの回数
ユーザー tnakao0123
提出日時 2025-06-07 17:35:27
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 692 bytes
コンパイル時間 602 ms
コンパイル使用メモリ 41,216 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2025-06-07 17:35:30
合計ジャッジ時間 2,677 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 33
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:27:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   27 |   scanf("%d", &tn);
      |   ~~~~~^~~~~~~~~~~
main.cpp:30:38: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 |     for (int i = 0; i < K; i++) scanf("%d", as + i);
      |                                 ~~~~~^~~~~~~~~~~~~~
main.cpp:31:38: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   31 |     for (int i = 0; i < K; i++) scanf("%d", bs + i);
      |                                 ~~~~~^~~~~~~~~~~~~~

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 3173.cc:  No.3173 縺倥c繧薙¢繧薙・蜍昴■縺ョ蝗樊焚 - yukicoder
 */

#include<cstdio>
#include<algorithm>

using namespace std;

/* constant */

const int K = 3;

/* typedef */

/* global variables */

int as[K], bs[K];

/* subroutines */

/* main */

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

  while (tn--) {
    for (int i = 0; i < K; i++) scanf("%d", as + i);
    for (int i = 0; i < K; i++) scanf("%d", bs + i);

    int mins = 0, maxs = 0;
    for (int i = 0; i < K; i++) {
      mins += max(0, as[i] - (bs[i] + bs[(i + 2) % K]));
      maxs += min(as[i], bs[(i + 1) % K]);
    }

    printf("%d %d\n", mins, maxs);
  }

  return 0;
}
0