Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include <iostream>#include <algorithm>using namespace std;#define SIZE 100000int M, N, w[SIZE], h[SIZE];void init(){pair<int, int> tmp;cin >> M >> N;for (int i = 0; i < N; ++i)cin >> w[i] >> h[i];}int getHeight(int sk){int ans, tw, th;ans = tw = th = 0;for (int i = 0; i < N; ++i){if (i == sk) continue;if (tw + w[i] < M){tw += w[i];th = max(th, h[i]);}else{if (tw + w[i] > M)th = max(th, (int)ceil(1.0 * (M - tw) / w[i] * h[i]));