結果
| 問題 |
No.672 最長AB列
|
| コンテスト | |
| ユーザー |
36_bocky
|
| 提出日時 | 2018-04-13 23:30:22 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 596 bytes |
| コンパイル時間 | 1,489 ms |
| コンパイル使用メモリ | 69,368 KB |
| 実行使用メモリ | 17,728 KB |
| 最終ジャッジ日時 | 2024-06-27 19:44:56 |
| 合計ジャッジ時間 | 1,692 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 WA * 6 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:35:12: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
35 | printf("%d\n", ans);
| ~^ ~~~
| | |
| int long long int
| %lld
ソースコード
#include <iostream>
#include <utility>
#include <map>
#include <algorithm>
using namespace std;
typedef pair<long long , long long>p;
int main()
{
long long rui[200001];
map<long long, long long> mp;
string str;
long long ans = 0;
cin >> str;
for ( int i = 0; i < str.size(); i++) {
if (str[i] == 'A' ) {
rui[i + 1] = rui[i] + 1;
} else {
rui[i + 1] = rui[i] - 1;
}
if ( mp.count(rui[i + 1]) == 0 ) {
mp[rui[i + 1]] = i + 1;
} else {
ans = max(ans, i + 1 - mp[rui[i + 1]] );
}
}
printf("%d\n", ans);
return (0);
}
36_bocky