結果

問題 No.393 2本の竹
ユーザー 👑 horiesinitihoriesiniti
提出日時 2016-06-20 14:41:42
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 834 bytes
コンパイル時間 721 ms
コンパイル使用メモリ 58,832 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-04-23 01:44:22
合計ジャッジ時間 6,110 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 4 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 5 ms
5,376 KB
testcase_08 AC 11 ms
5,376 KB
testcase_09 TLE -
testcase_10 AC 18 ms
5,376 KB
testcase_11 AC 214 ms
7,168 KB
testcase_12 AC 427 ms
7,552 KB
testcase_13 AC 126 ms
5,376 KB
testcase_14 AC 31 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 6 ms
5,376 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 4 ms
5,376 KB
testcase_22 AC 563 ms
9,472 KB
testcase_23 AC 64 ms
6,144 KB
testcase_24 AC 4 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘void f()’:
main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |         scanf("%d %d",&a1,&a2);
      |         ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |         scanf("%d",&m);
      |         ~~~~~^~~~~~~~~
main.cpp:15:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |                 scanf("%d",&c);
      |                 ~~~~~^~~~~~~~~
main.cpp: In function ‘int main()’:
main.cpp:50:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   50 |         scanf("%d",&d);
      |         ~~~~~^~~~~~~~~

ソースコード

diff #

#include<stdio.h>
#include<algorithm>
#include<map>
#include<vector>

void f(){
	int a1,a2,c;
	int m;
	int now=0,next=1;
	std::map<int,int> rf[2];
	std::vector<int> vec;
	scanf("%d %d",&a1,&a2);
	scanf("%d",&m);
	for(int i=0;i<m;i++){
		scanf("%d",&c);
		vec.push_back(c);
	}
	std::sort(vec.begin(),vec.end());
	int ans=0;
	rf[now][a1]=a2;
	while(rf[now].empty()==false){
		std::map<int,int>::iterator it;
		if(vec.size()==ans){
			break;
		}
		
		int c=vec[ans];
		for(it=rf[now].begin();it!=rf[now].end();it++){
			int x=(*it).first;
			int y=(*it).second;
			if(x>=c){
				rf[next][x-c]=y;
			}
			if(y>=c){
				rf[next][x]=y-c;
			}
		}
		if(rf[next].empty()==true){
			break;
		}
		ans++;
		rf[now].clear();
		std::swap(now,next);
	}
	printf("%d\n",ans);
}

int main(){
	int d;
	scanf("%d",&d);
	for(int i=0;i<d;i++){
		f();
	}
}
0