diff --git a/NYOJ/737.cpp b/NYOJ/737.cpp new file mode 100644 index 0000000..05e42f2 --- /dev/null +++ b/NYOJ/737.cpp @@ -0,0 +1,83 @@ +/**石子合并*/ +#include +#include +#include +#include +using namespace std; + +#define dprintf(format,args...) + +const int INF = 0x3f3f3f3f; +const int NINF = -INF -1; + +#define MAXN 10000 + +/** +inline void show(vector& s) +{ + printf("Stone: "); + for(auto& i:s) + { + printf("%d ",i); + } + printf("\n"); +} +//*/ + +#define show(s) + +void solve(int n) +{ + vector stone; + stone.push_back(INF); + for(int i=0;i3) + { + int k; + for(k=1;k=0;i--) + { + if(stone[i]>=tmp) + { + stone.insert(stone.begin()+i+1,tmp); + dprintf("After Insertion :\n");show(stone); + break; + } + } + } + printf("%d\n",sum); +} + +int main() +{ + int n; + while(scanf("%d",&n)==1&&n!=0) solve(n); + return 0; +}