結果
問題 | No.204 ゴールデン・ウィーク(2) |
ユーザー |
|
提出日時 | 2024-12-18 00:31:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 902 bytes |
コンパイル時間 | 2,168 ms |
コンパイル使用メモリ | 190,948 KB |
最終ジャッジ日時 | 2025-02-26 15:11:34 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
ソースコード
#include <bits/stdc++.h> using namespace std; int d,ans; // 从下标0开始模拟连续的42天 char s[50],t[50]; int main(){ cin>>d; // 前14和后14个下标填x, 中间14个下标输入 for(int i=0,j=14,k=28;i<14;++i,++j,++k){ s[i]=s[k]='x'; cin>>s[j]; } // i: 枚举每一个可以开始请假的日期 for(int i=0;i<=28;++i){ strcpy(t,s); // 假期只能用在工作日, 所以遇到o就跳过 if(t[i]=='o') continue; // 连续的d天请假,遇到o就停止 for(int j=0;j<d;++j){ if(t[i+j]=='o') break; t[i+j]='o'; } // 计算42天中连续o的数量的最大值 int cnt=0; for(int j=0;j<42;++j) if(t[j]=='o'){ ++cnt; ans=max(ans,cnt); }else cnt=0; } cout<<ans; return 0; }