結果
| 問題 |
No.1454 ツブ消ししとるなEasy
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2021-03-31 21:10:56 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 524 bytes |
| コンパイル時間 | 1,926 ms |
| コンパイル使用メモリ | 198,256 KB |
| 最終ジャッジ日時 | 2025-01-20 02:37:57 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 15 WA * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:24:12: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘ll’ {aka ‘long long int’} [-Wformat=]
24 | printf("%d\n",ans);
| ~^ ~~~
| | |
| int ll {aka long long int}
| %lld
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--; }
}
sort(A.begin(),A.end(),greater<int>());
if(C<0){ printf("Handicapped\n"); return 0; }
rep(i,min(C,(int)A.size())) ans+=A[i];
printf("%d\n",ans);
return 0;
}
Nachia