結果
問題 |
No.393 2本の竹
|
ユーザー |
![]() |
提出日時 | 2016-06-20 14:41:42 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 834 bytes |
コンパイル時間 | 561 ms |
コンパイル使用メモリ | 58,828 KB |
実行使用メモリ | 11,648 KB |
最終ジャッジ日時 | 2024-10-15 00:59:28 |
合計ジャッジ時間 | 5,243 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 TLE * 2 |
コンパイルメッセージ
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); | ~~~~~^~~~~~~~~
ソースコード
#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(); } }