結果
| 問題 |
No.1736 Princess vs. Dragoness
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-01-15 11:16:33 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 877 bytes |
| コンパイル時間 | 656 ms |
| コンパイル使用メモリ | 77,216 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-07-04 14:07:37 |
| 合計ジャッジ時間 | 1,679 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:19:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
19 | scanf("%d%d%d%lld%lld",&n,&a,&b,&x,&y);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:24:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
24 | scanf("%d",&h[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#define rep(i,n) for(i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
int n,a,b;
ll x,y;
int main(){
int i,j,cnt;
ll p,d;
P now;
scanf("%d%d%d%lld%lld",&n,&a,&b,&x,&y);
vector<int> h(n);
cnt=n;
priority_queue<P> PQ;
rep(i,n){
scanf("%d",&h[i]);
PQ.push(P(h[i],i));
}
while(PQ.size()&&a>0){
now=PQ.top();PQ.pop();
h[now.second]-=x;
now.first=h[now.second];
if(h[now.second]<=0)cnt--;
else PQ.push(now);
a--;
}
p=y*b;
rep(i,n){
if(h[i]>0){
d=min((ll)h[i],p);
h[i]-=d;
p-=d;
if(h[i]<=0)cnt--;
}
}
printf("%s\n",cnt==0?"Yes":"No");
return 0;
}