From 15ecf803d9217d72b52d5ca6309f1d9dc3254c67 Mon Sep 17 00:00:00 2001 From: Kirito <1362050620@qq.com> Date: Tue, 2 Aug 2016 15:49:14 +0800 Subject: [PATCH] Create 737.cpp --- NYOJ/737.cpp | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 NYOJ/737.cpp 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; +}