結果

問題 No.3065 Speedrun (Normal)
ユーザー tnakao0123
提出日時 2025-03-22 18:18:01
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 754 bytes
コンパイル時間 545 ms
コンパイル使用メモリ 45,312 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-22 18:18:02
合計ジャッジ時間 1,282 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:31:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   31 |   for (int i = 0; i < M; i++) scanf("%d", as + i);
      |                               ~~~~~^~~~~~~~~~~~~~
main.cpp:32:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   32 |   for (int i = 0; i < M; i++) scanf("%d", ps + i);
      |                               ~~~~~^~~~~~~~~~~~~~
main.cpp:34:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   34 |   scanf("%lld", &t);
      |   ~~~~~^~~~~~~~~~~~

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 3065.cc:  No.3065 Speedrun (Normal) - yukicoder
 */

#include<cstdio>
#include<algorithm>
#include<utility>

using namespace std;

/* constant */

const int M = 4;

/* typedef */

using ll = long long;
using pii = pair<int,int>;

/* global variables */

int as[M], ps[M];
pii pas[M];

/* subroutines */

/* main */

int main() {
  for (int i = 0; i < M; i++) scanf("%d", as + i);
  for (int i = 0; i < M; i++) scanf("%d", ps + i);
  ll t;
  scanf("%lld", &t);

  for (int i = 0; i < M; i++) pas[i] = {ps[i], as[i]};
  sort(pas, pas + M);

  ll sum = 0;
  for (int i = 0; i < M; i++) {
    auto [pi, ai] = pas[i];
    ll d = min(t / pi, (ll)ai);
    sum += d;
    t -= d * pi;
  }

  printf("%lld\n", sum);
  
  return 0;
}
0