結果

問題 No.1454 ツブ消ししとるなEasy
ユーザー 👑 Nachia
提出日時 2021-03-31 21:09:47
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 512 bytes
コンパイル時間 1,980 ms
コンパイル使用メモリ 197,040 KB
最終ジャッジ日時 2025-01-20 02:36:32
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 2
other AC * 10 WA * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
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);
      |            ~~~~~^~~~~~~~~

ソースコード

diff #

#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(A.size()<C){ printf("Handicapped\n"); return 0; }
  rep(i,C) ans+=A[i];
  printf("%d\n",ans);
  return 0;
}
0