Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include <iostream>#include <climits>#include <cmath>using namespace std;int fig[100005][2];int dp[100005][2];int main(){int M,N;cin >> M >> N;for(int i=0; i<N; i++){cin>>fig[i][0] >> fig[i][1];}for(int i=0; i<N; i++){int width = M;int curheight = -1;int j = i;for(; j<N; j++){if(width > 0 && width >= fig[j][0]){curheight = max(curheight, fig[j][1]);width -= fig[j][0];}else if(width > 0 && width < fig[j][0]){double rate = fig[j][0]*1.0/width;int h = ceil(fig[j][1]/rate);width = 0;curheight = max(curheight, h);