提出 #27554776
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < (int)n; i++)
#define REP(i, n) FOR(i, 0, n)
string S;
int K;
int Si(int idx) { return (S[idx] == '.'); }
int main() {
cin >> S >> K;
int res = 0;
int s = 0;
int t = 0;
int sum = 0;
for (;;) {
while (t < S.size() && sum + Si(t) <= K) {
sum += Si(t++);
}
if (s == S.size()) { break; }
res = max(res, t-s);
sum -= Si(s++);
}
cout << res << endl;
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | D - Longest X |
| ユーザ | ryo_ryo66 |
| 言語 | C++ (GCC 9.2.1) |
| 得点 | 400 |
| コード長 | 524 Byte |
| 結果 | AC |
| 実行時間 | 13 ms |
| メモリ | 3756 KiB |
コンパイルエラー
./Main.cpp: In function ‘int main()’:
./Main.cpp:21:14: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
21 | while (t < S.size() && sum + Si(t) <= K) {
| ~~^~~~~~~~~~
./Main.cpp:24:11: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
24 | if (s == S.size()) { break; }
| ~~^~~~~~~~~~~
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 400 / 400 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | example0.txt, example1.txt |
| All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, example0.txt, example1.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 000.txt | AC | 9 ms | 3608 KiB |
| 001.txt | AC | 3 ms | 3500 KiB |
| 002.txt | AC | 3 ms | 3636 KiB |
| 003.txt | AC | 2 ms | 3640 KiB |
| 004.txt | AC | 8 ms | 3652 KiB |
| 005.txt | AC | 7 ms | 3652 KiB |
| 006.txt | AC | 3 ms | 3580 KiB |
| 007.txt | AC | 2 ms | 3508 KiB |
| 008.txt | AC | 9 ms | 3708 KiB |
| 009.txt | AC | 10 ms | 3652 KiB |
| 010.txt | AC | 9 ms | 3576 KiB |
| 011.txt | AC | 11 ms | 3692 KiB |
| 012.txt | AC | 10 ms | 3696 KiB |
| 013.txt | AC | 8 ms | 3628 KiB |
| 014.txt | AC | 13 ms | 3688 KiB |
| 015.txt | AC | 10 ms | 3652 KiB |
| 016.txt | AC | 6 ms | 3636 KiB |
| 017.txt | AC | 9 ms | 3652 KiB |
| 018.txt | AC | 13 ms | 3656 KiB |
| 019.txt | AC | 7 ms | 3652 KiB |
| 020.txt | AC | 7 ms | 3652 KiB |
| 021.txt | AC | 13 ms | 3536 KiB |
| 022.txt | AC | 9 ms | 3532 KiB |
| 023.txt | AC | 11 ms | 3716 KiB |
| 024.txt | AC | 11 ms | 3756 KiB |
| 025.txt | AC | 10 ms | 3652 KiB |
| 026.txt | AC | 10 ms | 3744 KiB |
| 027.txt | AC | 9 ms | 3648 KiB |
| 028.txt | AC | 9 ms | 3636 KiB |
| 029.txt | AC | 9 ms | 3536 KiB |
| 030.txt | AC | 12 ms | 3712 KiB |
| 031.txt | AC | 8 ms | 3580 KiB |
| 032.txt | AC | 12 ms | 3712 KiB |
| 033.txt | AC | 13 ms | 3652 KiB |
| 034.txt | AC | 9 ms | 3756 KiB |
| example0.txt | AC | 2 ms | 3520 KiB |
| example1.txt | AC | 2 ms | 3564 KiB |