結果

問題 No.1736 Princess vs. Dragoness
ユーザー tnakao0123
提出日時 2021-11-13 18:50:58
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 892 bytes
コンパイル時間 400 ms
コンパイル使用メモリ 54,384 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-07-04 14:05:38
合計ジャッジ時間 1,401 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:33:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   33 |   scanf("%d%d%d%d%d", &n, &a, &b, &x, &y);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:34:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   34 |   for (int i = 0; i < n; i++) scanf("%d", hs + i);
      |                               ~~~~~^~~~~~~~~~~~~~

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1736.cc:  No.1736 Princess vs. Dragoness - yukicoder
 */

#include<cstdio>
#include<queue>
#include<algorithm>
 
using namespace std;

/* constant */

const int MAX_N = 3000;

/* typedef */

typedef long long ll;
typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

int hs[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, a, b, x, y;
  scanf("%d%d%d%d%d", &n, &a, &b, &x, &y);
  for (int i = 0; i < n; i++) scanf("%d", hs + i);

  priority_queue<int> q(hs, hs + n);
  
  while (a > 0 && ! q.empty()) {
    int h = q.top(); q.pop();
    if (h >= x) {
      int d = min(a, h / x);
      h -= d * x, a -= d;
    }
    else
      h -= x, a--;
    if (h > 0) q.push(h);
  }

  ll sum = 0;
  while (! q.empty()) sum += q.top(), q.pop();

  if (sum <= (ll)y * b) puts("Yes");
  else puts("No");
  return 0;
}
0