結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
hikomimo
|
| 提出日時 | 2015-01-25 16:59:42 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,404 bytes |
| コンパイル時間 | 676 ms |
| コンパイル使用メモリ | 96,848 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-17 22:18:48 |
| 合計ジャッジ時間 | 1,503 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, const char**)’:
main.cpp:56:13: warning: ‘res’ may be used uninitialized in this function [-Wmaybe-uninitialized]
56 | cout << res << endl;
| ^~~
main.cpp:49:15: warning: ‘tmp’ may be used uninitialized in this function [-Wmaybe-uninitialized]
49 | if(tmp+W[i]<=L) {
ソースコード
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(x,a,b) for(int x=a;x<b;x++)
#define FORSIZE(x,A) for(int x=0;x<A.size();x++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define SORT(x) sort(x.begin(),x.end())
#define RSORT(x) sort(x.rbegin(),x.rend())
#define rsort(x,n) sort(x, x+n, greater<int>())
#define REV(x) reverse(x.begin(),x.end())
#define REP(x,a) FOR(x,0,a)
using namespace std;
typedef long long ll;
inline int toInt(std::string s) {int v; std::istringstream sin(s);sin>>v;return v;}
template<class T> inline std::string toString(T x) {std::ostringstream sout;sout<<x;return sout.str();}
int main( int argc, const char* argv[] )
{
int L, N;
int tmp, res;
vector<int> W;
cin >> L >> N;
W.assign(N, 0);
REP(i,N) cin >> W[i];
SORT(W);
FORSIZE(i,W) {
if(tmp+W[i]<=L) {
tmp += W[i];
res += 1;
} else {
break;
}
}
cout << res << endl;
return 0;
}
hikomimo