結果
問題 | No.1454 ツブ消ししとるなEasy |
ユーザー |
👑 ![]() |
提出日時 | 2021-03-31 21:13:43 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 526 bytes |
コンパイル時間 | 1,950 ms |
コンパイル使用メモリ | 197,968 KB |
最終ジャッジ日時 | 2025-01-20 02:40:59 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:12:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%d%d%d%d",&N,&M,&X,&Y); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:16:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 16 | int x; scanf("%d",&x); | ~~~~~^~~~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; using ll=long long; using ull=unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) int N,M,X,Y; vector<int> A; int C; int main(){ scanf("%d%d%d%d",&N,&M,&X,&Y); C = M; ll ans=0; rep(i,N){ int x; scanf("%d",&x); if(x<=Y) ; else if(x<X) A.push_back(x); else{ ans+=x; C--; } } if(C<0){ printf("Handicapped\n"); return 0; } sort(A.begin(),A.end(),greater<int>()); rep(i,min(C,(int)A.size())) ans+=A[i]; printf("%lld\n",ans); return 0; }