提出 #18063369
ソースコード 拡げる
/*
after dusk passed,
there is a starry sky.
*/
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define m_k make_pair
using namespace std;
const int N=110;
int n,ans;
char s[N];
signed main()
{
scanf("%s",s+1);
n=strlen(s+1);ans=inf;
for (int i=0;i<26;i++)
{
int last=0,MAX=0;
for (int j=1;j<=n;j++) if (s[j]=='a'+i) MAX=max(MAX,j-last-1),last=j;
MAX=max(MAX,n-last);
ans=min(ans,MAX);
}
printf("%d\n",ans);
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | A - Shrinking |
| ユーザ | SevenDawns |
| 言語 | C++ (GCC 9.2.1) |
| 得点 | 300 |
| コード長 | 448 Byte |
| 結果 | AC |
| 実行時間 | 8 ms |
| メモリ | 3740 KiB |
コンパイルエラー
./Main.cpp: In function ‘int main()’:
./Main.cpp:14:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
14 | scanf("%s",s+1);
| ~~~~~^~~~~~~~~~
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 300 / 300 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt |
| All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 0_00.txt | AC | 8 ms | 3676 KiB |
| 0_01.txt | AC | 2 ms | 3724 KiB |
| 0_02.txt | AC | 2 ms | 3536 KiB |
| 0_03.txt | AC | 2 ms | 3680 KiB |
| 1_00.txt | AC | 3 ms | 3624 KiB |
| 1_01.txt | AC | 2 ms | 3536 KiB |
| 1_02.txt | AC | 2 ms | 3740 KiB |
| 1_03.txt | AC | 2 ms | 3540 KiB |
| 1_04.txt | AC | 3 ms | 3596 KiB |
| 1_05.txt | AC | 2 ms | 3564 KiB |
| 1_06.txt | AC | 2 ms | 3564 KiB |
| 1_07.txt | AC | 2 ms | 3632 KiB |
| 1_08.txt | AC | 3 ms | 3564 KiB |
| 1_09.txt | AC | 2 ms | 3680 KiB |