結果
| 問題 | No.5 数字のブロック |
| コンテスト | |
| ユーザー |
wacchoz
|
| 提出日時 | 2019-11-22 22:40:57 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,733 bytes |
| 記録 | |
| コンパイル時間 | 995 ms |
| コンパイル使用メモリ | 182,328 KB |
| 実行使用メモリ | 7,972 KB |
| 最終ジャッジ日時 | 2026-04-27 10:40:26 |
| 合計ジャッジ時間 | 2,396 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 WA * 10 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ostream:42,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/istream:43,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/sstream:42,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/complex:50,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ccomplex:43,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:133,
from main.cpp:1:
In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>]',
inlined from 'int main()' at main.cpp:116:13:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ostream.h:212:25: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
212 | { return _M_insert(__n); }
| ~~~~~~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:111:16: note: 'ans' was declared here
111 | int t = 0, ans;
| ^~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long
//typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
for (T& x : vec) is >> x;
return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
os << "(" << pair_var.first << ", " << pair_var.second << ")";
return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
os << "{";
for (int i = 0; i < vec.size(); i++) {
os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
}
os << "}";
return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
os << "{";
repi(itr, map_var) {
os << *itr;
itr++;
if (itr != map_var.end()) os << ", ";
itr--;
}
os << "}";
return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
os << "{";
repi(itr, set_var) {
os << *itr;
itr++;
if (itr != set_var.end()) os << ", ";
itr--;
}
os << "}";
return os;
}
#define DUMPOUT cerr
void dump_func() {
DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
DUMPOUT << head;
if (sizeof...(Tail) > 0) {
DUMPOUT << ", ";
}
dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...) \
DUMPOUT << " " << string(#__VA_ARGS__) << ": " \
<< "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" \
<< endl \
<< " ", \
dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif
signed main() {
int L,N;
cin >> L >> N;
vector<int> W(N);
rep(i,N) cin >> W[i];
sort(W.begin(), W.end());
int t = 0, ans;
rep(i,N){
if(t+W[i]>L){ans=i; break;}
t+=W[i];
}
cout << ans << endl;
return 0;
}
wacchoz