记录编号 | 391701 | 评测结果 | AAAAAAAAAA | ||
---|---|---|---|---|---|
题目名称 | 划分数列 | 最终得分 | 100 | ||
用户昵称 | 是否通过 | 通过 | |||
代码语言 | C++ | 运行时间 | 0.068 s | ||
提交时间 | 2017-04-06 17:48:21 | 内存使用 | 0.70 MiB | ||
#include <iostream> #include <cstdio> #include <fstream> #include <algorithm> #include <cmath> #include <deque> #include <vector> #include <queue> #include <string> #include <cstring> #include <map> #include <stack> #include <set> #define mylove Turkey; using namespace std; const int maxn=100005; const int inf=99999; int n,m,mo[maxn],sum=0,h=0,z,hh=0,max1=-100; typedef int itn; typedef long long ll; int main() { freopen("seqa.in","r",stdin); freopen("seqa.out","w",stdout); scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) { scanf("%d",&mo[i]); hh+=mo[i]; max1=max(max1,mo[i]); }itn x=max1,y=hh; while(x<=y) { h=1; sum=0; z=(x+y)/2; for(int i=1;i<=n;i++) { sum+=mo[i]; if(sum>z) { h++; sum=mo[i]; } } // if(h==m)break; if(h>m) { x=z+1; } if(h<=m) y=z-1; } cout<<x; fclose(stdin); fclose(stdout); return 0; }