当前位置:网站首页>Educational Codeforces Round 20 D. Magazine Ad
Educational Codeforces Round 20 D. Magazine Ad
2022-06-09 05:56:00 【No toast】
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define eps 1e-2
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;
const int maxn = 1e6+2;
const int INF = 1<<30;
const int mod = 1e9+7;
char ch[maxn];int len=0,k;
std::vector<int> v;
bool check(int x){
int now=0,cnt=1;
for(int i=0;i<v.size();i++){
now+=v[i];
if(now>x){
++cnt;
now=v[i];
}
}
return cnt<=k;
}
void solve(){
cin>>k;
getchar();
while(1){
char c=getchar();
if(c=='\n') break;
ch[++len]=c;
}
int pre=0;
for(int i=1;i<=len;i++){
if(ch[i]==' '||ch[i]=='-'){
v.push_back(i-pre);
pre=i;
}
}
v.push_back(len-pre);
// for(auto it:v) cout<<it<<endl;
int l=0,r=len;for(auto it:v) l=max(l,it);
while(l<r){
int mid=(l+r)/2;
if(check(mid)) r=mid;
else l=mid+1;
}
cout<<l<<endl;
return;
}
int main()
{
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
// ios::sync_with_stdio(false);
int t = 1;
//scanf("%d",&t);
while(t--){
// printf("Case %d: ",cas++);
solve();
}
return 0;
}
边栏推荐
- 线程thread 中join方法解读
- VK Cup 2017 - Round 2 B. Volatile Kite
- 代码签名证书的时间戳验证码签名方法
- Painstakingly wrote a detailed MySQL tutorial of 24K words in three days, three nights
- Practical guide to GStreamer application development (IV)
- 测试和线程
- js 获取url参数并且进行中文解析
- “Ran out of input” while use WikiExtractor
- Swift extension
- Several implementation methods of redis distributed lock
猜你喜欢

三大队列cxq,entrylist,waitset 个人理解分析

Redis cache avalanche, penetration and breakdown

Synchronized detailed parsing

Thread interrupted detailed parsing

Complete jitsi meet guide for webrtc

传输介质双绞线和光纤及二进制

SSL證書包含了哪些信息?

【论文】CBAM: Convolutional Block Attention Module

Bubble sort, print diamond, print right triangle, print inverted triangle, print equilateral triangle, print 99 multiplication table

SSL证书包含了哪些信息?
随机推荐
VK Cup 2017 - Round 1 C. Bear and Tree Jumps 换根dp
Gstreamer应用开发实战指南(一)
arthas-boot
@Differences between jsonformat and @datetimeformat
In latex, \cdots is followed by a sentence. What's wrong with the format of the following sentence.
Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) C. Jon Snow and his Favou
Two methods of unbutu installing ffmpeg
This paper gives a comprehensive overview of the application, methods and classification of the multi traveling salesman problem
DTD的概念及编写
Quelles sont les informations contenues dans le certificat SSL?
Bubble sort, print diamond, print right triangle, print inverted triangle, print equilateral triangle, print 99 multiplication table
Axure cracking code
XML modeling
Practical guide to GStreamer application development (IV)
Record TCP time once_ Blood cases caused by wait
Gstreamer应用开发实战指南(二)
Yoyov5's tricks | [trick7] exponential moving average (EMA)
使用MAT进行内存问题定位
微信小程序wx.getLocation定位错误信息汇总
Yolov5-6.0 series | yolov5 module design