結果

問題 No.5 数字のブロック
ユーザー y32M-71693993y32M-71693993
提出日時 2015-09-27 17:07:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 3,513 bytes
コンパイル時間 1,282 ms
コンパイル使用メモリ 161,376 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-18 07:37:48
合計ジャッジ時間 2,208 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,820 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 1 ms
6,816 KB
testcase_03 AC 2 ms
6,820 KB
testcase_04 AC 2 ms
6,820 KB
testcase_05 AC 3 ms
6,816 KB
testcase_06 AC 3 ms
6,820 KB
testcase_07 AC 2 ms
6,820 KB
testcase_08 AC 2 ms
6,816 KB
testcase_09 AC 2 ms
6,820 KB
testcase_10 AC 3 ms
6,820 KB
testcase_11 AC 2 ms
6,816 KB
testcase_12 AC 3 ms
6,820 KB
testcase_13 AC 3 ms
6,816 KB
testcase_14 AC 2 ms
6,816 KB
testcase_15 AC 1 ms
6,820 KB
testcase_16 AC 3 ms
6,816 KB
testcase_17 AC 3 ms
6,820 KB
testcase_18 AC 3 ms
6,820 KB
testcase_19 AC 3 ms
6,820 KB
testcase_20 AC 1 ms
6,820 KB
testcase_21 AC 2 ms
6,820 KB
testcase_22 AC 1 ms
6,816 KB
testcase_23 AC 2 ms
6,820 KB
testcase_24 AC 2 ms
6,820 KB
testcase_25 AC 2 ms
6,820 KB
testcase_26 AC 1 ms
6,816 KB
testcase_27 AC 1 ms
6,820 KB
testcase_28 AC 1 ms
6,820 KB
testcase_29 AC 2 ms
6,816 KB
testcase_30 AC 2 ms
6,816 KB
testcase_31 AC 1 ms
6,816 KB
testcase_32 AC 1 ms
6,816 KB
testcase_33 AC 1 ms
6,816 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:38:27: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   38 | #define SCANF_INT(a) scanf("%d", &(a));
      |                      ~~~~~^~~~~~~~~~~~
main.cpp:10:9: note: in expansion of macro ‘SCANF_INT’
   10 |         FIRST(A) NEXT(B)
      |         ^~~~~
main.cpp:5:69: note: in expansion of macro ‘EXPAND_02’
    5 | #define GET_MACRO_09(A1, A2, A3, A4, A5, A6, A7, A8, A9, NAME, ...) NAME
      |                                                                     ^~~~
main.cpp:29:28: note: in expansion of macro ‘EXPAND_ADD’
   29 | #define EXPAND(MACRO, ...) EXPAND_ADD(MACRO, MACRO, __VA_ARGS__)
      |                            ^~~~~~~~~~
main.cpp:41:33: note: in expansion of macro ‘EXPAND’
   41 | #define I(...) int __VA_ARGS__; EXPAND(SCANF_INT, __VA_ARGS__);
      |                                 ^~~~~~
main.cpp:95:9: note: in expansion of macro ‘I’
   95 |         I(l, n);
      |         ^
main.cpp:38:27: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   38 | #define SCANF_INT(a) scanf("%d", &(a));
      |                      ~~~~~^~~~~~~~~~~~
main.cpp:10:18: note: in expansion of macro ‘SCANF_INT’
   10 |         FIRST(A) NEXT(B)
      |                  ^~~~
main.cpp:5:69: note: in expansion of macro ‘EXPAND_02’
    5 | #define GET_MACRO_09(A1, A2, A3, A4, A5, A6, A7, A8, A9, NAME, ...) NAME
      |                                                                     ^~~~
main.cpp:29:28: note: in expansion of macro ‘EXPAND_ADD’
   29 | #define EXPAND(MACRO, ...) EXPAND_ADD(MACRO, MACRO, __VA_ARGS__)
      |                            ^~~~~~~~~~
main.cpp:41:33: note: in expansion of macro ‘EXPAND’
   41 | #define I(...) int __VA_ARGS__; EXPAND(SCANF_INT, __VA_ARGS__);
      |                       

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

// Macro Tools /////////////////////////////////////////////////////////////////
#define GET_MACRO_09(A1, A2, A3, A4, A5, A6, A7, A8, A9, NAME, ...) NAME

#define EXPAND_01(FIRST, NEXT, A) \
	FIRST(A)
#define EXPAND_02(FIRST, NEXT, A, B) \
	FIRST(A) NEXT(B)
#define EXPAND_03(FIRST, NEXT, A, B, C) \
	FIRST(A) NEXT(B) NEXT(C)
#define EXPAND_04(FIRST, NEXT, A, B, C, D) \
	FIRST(A) NEXT(B) NEXT(C) NEXT(D)
#define EXPAND_05(FIRST, NEXT, A, B, C, D, E) \
	FIRST(A) NEXT(B) NEXT(C) NEXT(D) NEXT(E)
#define EXPAND_06(FIRST, NEXT, A, B, C, D, E, F) \
	FIRST(A) NEXT(B) NEXT(C) NEXT(D) NEXT(E) NEXT(F)
#define EXPAND_07(FIRST, NEXT, A, B, C, D, E, F, G) \
	FIRST(A) NEXT(B) NEXT(C) NEXT(D) NEXT(E) NEXT(F) NEXT(G)
#define EXPAND_08(FIRST, NEXT, A, B, C, D, E, F, G, H) \
	FIRST(A) NEXT(B) NEXT(C) NEXT(D) NEXT(E) NEXT(F) NEXT(G) NEXT(H)
#define EXPAND_09(FIRST, NEXT, A, B, C, D, E, F, G, H, I) \
	FIRST(A) NEXT(B) NEXT(C) NEXT(D) NEXT(E) NEXT(F) NEXT(G) NEXT(H) NEXT(I)
#define EXPAND_ADD(FIRST, NEXT, ...) \
	GET_MACRO_09(__VA_ARGS__, EXPAND_09, EXPAND_08, EXPAND_07, EXPAND_06, \
		EXPAND_05, EXPAND_04, EXPAND_03, EXPAND_02, EXPAND_01) \
	(FIRST, NEXT, __VA_ARGS__)
#define EXPAND(MACRO, ...) EXPAND_ADD(MACRO, MACRO, __VA_ARGS__)

#define Q(x) #x
#define QUOTE(x) Q(x)

// Input ///////////////////////////////////////////////////////////////////////
#define RIGHT_SHIFT_BEFORE(a) >>a
#define CAMMA_AND_ADDRESS(a) , &a
#define INT_FORMATTER(a) %d
#define SCANF_INT(a) scanf("%d", &(a));
// #define SCANF_LL(a) scanf("%I64d", &(a));

#define I(...) int __VA_ARGS__; EXPAND(SCANF_INT, __VA_ARGS__);
// #define L(...) long long __VA_ARGS__; EXPAND(SCANF_LL, __VA_ARGS__);

#define input(t,v) t v;cin>>v;
#define input2(t,v1,v2) t v1,v2;cin>>v1>>v2;
#define input3(t,v1,v2,v3) t v1,v2,v3;cin>>v1>>v2>>v3;

#if __cplusplus > 199711L  //C++11
template<class T=int>
#else
template<class T>
#endif
T read() {
	T t;
	cin >> t;
	return t;
}

// Types ///////////////////////////////////////////////////////////////////////
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef set<int> si;
typedef set<ll, ll> sll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef list<int> li;
typedef list<ll> lll;
typedef map<int, int> mii;
typedef map<int, ll> mil;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;

// Loop & Iteration ////////////////////////////////////////////////////////////
#define FOR(i, a, b) for(int i = (a), loop_end_##i=(b); i < (loop_end_##i); i++)
#define REP(i, n) FOR(i, 0, n)
#define rep(v,n) for(int (v)=0;(v)<(n);(v)++)
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort((c).begin(),(c).end())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define PB push_back

// Range ///////////////////////////////////////////////////////////////////////
#define IN(x, a, b) (a<=x && x<b)
int dx[8] = { 1, 0, 0,-1, 1, 1,-1,-1};
int dy[8] = { 0,-1, 1, 0,-1, 1,-1, 1};

// Debug ///////////////////////////////////////////////////////////////////////
#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

////////////////////////////////////////////////////////////////////////////////

int main(){
	I(l, n);
	int x[n];
	REP(i, n){
		I(a);
		x[i]=a;
	}
	sort(x, x+n);
	int sum = 0;
	int i = 0;
	while(i<n){
		if(sum+x[i]<=l) sum+=x[i++];
		else break;
		// printf("%d\n", sum);
	}
	printf("%d\n", i);
}
0