結果
問題 | No.5 数字のブロック |
ユーザー |
![]() |
提出日時 | 2017-08-18 15:13:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 684 bytes |
コンパイル時間 | 2,303 ms |
コンパイル使用メモリ | 195,232 KB |
最終ジャッジ日時 | 2025-01-05 02:22:46 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 RE * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:20:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | scanf("%d%d",&l,&n); | ~~~~~^~~~~~~~~~~~~~ main.cpp:22:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 22 | scanf("%d",w + i); | ~~~~~^~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h> typedef long long ll; typedef unsigned long long ull; using namespace std; #define pb push_back int dy[]={0, 0, 1, -1, 1, 1, -1, -1}; int dx[]={1, -1, 0, 0, 1, -1, -1, 1}; #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--) #define REP(i,n) for (int i=0;i<(n);i++) #define RREP(i,n) for (int i=(n)-1;i>=0;i--) #define mp make_pair #define fi first #define sc second int w[10000]; int main(){ int l,n; scanf("%d%d",&l,&n); REP(i,n) scanf("%d",w + i); sort(w,w + n); int c = 0; int lc = 0; while(lc + w[c] <= l){ lc += w[c];c++; } printf("%d\n",c); return 0; }