結果
| 問題 | No.204 ゴールデン・ウィーク(2) |
| コンテスト | |
| ユーザー |
fal_rnd
|
| 提出日時 | 2017-02-18 13:43:54 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 982 bytes |
| 記録 | |
| コンパイル時間 | 2,313 ms |
| コンパイル使用メモリ | 160,660 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-24 11:58:06 |
| 合計ジャッジ時間 | 3,180 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 46 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,s,g) for(int i=s;i<g;i++)
#define REP(i, n) for(int i=0;i<n;i++)
using ull = unsigned long long;
using ll = long long;
const char en = '\n';
const ull INFL = 810000001919114514;
const ull INF = 1919114514;
int d;
using D = vector<int>;
D in;
int main(){
cin.tie();ios::sync_with_stdio(false);
cin>>d;
char curc='x',buf;
int curv=114514;
REP(i,14){
cin>>buf;
if(buf==curc){
curv++;
}else{
curc=buf;
in.push_back(curv);
curv=1;
}
}
if(curc=='x'){
in.push_back(curv+114514);
}else{
in.push_back(curv);
in.push_back(114514);
}
in.push_back(0);
/*
for(int i=0;i<in.size();i++){
cout<<in[i]<<' ';
}
cout<<en;
*/
int result=d+in[1];
for(int i=2;i<in.size()-1;i+=2){
if(in[i]<=d){
result=max(result,in[i-1]+in[i]+in[i+1]);
}else{
result=max(result, in[i-1]+d);
result=max(result, in[i+1]+d);
}
}
cout<<result<<en;
return 0;
}
fal_rnd