結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
kyawashell
|
| 提出日時 | 2017-08-18 15:15:28 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 5,000 ms |
| コード長 | 694 bytes |
| コンパイル時間 | 2,099 ms |
| コンパイル使用メモリ | 193,852 KB |
| 最終ジャッジ日時 | 2025-01-05 02:22:55 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:21:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
21 | scanf("%d%d",&l,&n);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:23:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
23 | 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(c < n && lc + w[c] <= l){
lc += w[c];c++;
}
printf("%d\n",c);
return 0;
}
kyawashell