Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include <iostream>#include <vector>#include <algorithm>#include <limits.h>using namespace std;const int maxCount = 100000 + 1;int w[maxCount] = { 0 }, h[maxCount] = { 0 };int first[maxCount] = { 0 };int Next[maxCount] = { 0 };int partSum[maxCount] = { 0 };int posRow[maxCount] = { 0 };int M, N;class tryReturn {public:int maxhei;int latter;};tryReturn oneTry(int front){int tail = front;int sum = 0, maxh = 0;while (sum < M && tail<N){if (sum + w[tail] <= M){maxh = (maxh < h[tail]) ? h[tail] : maxh;sum += w[tail];}else{double ratio = double(M - sum) / double(w[tail]);