結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2020-11-24 15:12:46 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 5,000 ms |
コード長 | 778 bytes |
コンパイル時間 | 2,048 ms |
コンパイル使用メモリ | 197,416 KB |
最終ジャッジ日時 | 2025-01-16 05:23:47 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:12:28: warning: ‘ans’ may be used uninitialized [-Wmaybe-uninitialized] 12 | #define COUT(x) cout<<(x)<<"\n" | ^~~~ main.cpp:31:5: note: in expansion of macro ‘COUT’ 31 | COUT(ans); | ^~~~ main.cpp:25:9: note: ‘ans’ was declared here 25 | int ans; | ^~~
ソースコード
#include <bits/stdc++.h> typedef long long ll; using namespace std; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const int INF = 1e9; const int MOD = 1e9+7; const ll LINF = 1e18; #define REP(i,n) for(int i=0;i<(n);++i) #define COUT(x) cout<<(x)<<"\n" #define COUT16(x) cout << fixed << setprecision(16) << (x) << "\n"; int main(){ int l,n; cin >> l >> n; vector<int>w(n); REP(i,n)cin >> w[i]; sort(w.begin(),w.end()); vector<int> wa(n+1,0); REP(i,n){ wa[i+1] = wa[i] + w[i]; } int ans; for(int i=0;i<=n;i++){ if(wa[i]<=l){ ans = i; } } COUT(ans); }