結果

問題 No.1512 作文
ユーザー shiomusubi496shiomusubi496
提出日時 2021-05-21 21:28:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 506 bytes
コンパイル時間 2,601 ms
コンパイル使用メモリ 205,476 KB
実行使用メモリ 9,644 KB
最終ジャッジ日時 2024-04-18 14:29:11
合計ジャッジ時間 4,283 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 51 ms
7,496 KB
testcase_05 AC 50 ms
7,528 KB
testcase_06 AC 51 ms
7,424 KB
testcase_07 AC 50 ms
7,432 KB
testcase_08 AC 49 ms
7,552 KB
testcase_09 AC 5 ms
5,376 KB
testcase_10 AC 6 ms
5,376 KB
testcase_11 AC 5 ms
5,376 KB
testcase_12 AC 5 ms
5,376 KB
testcase_13 AC 5 ms
5,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 WA -
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 WA -
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
testcase_34 AC 3 ms
5,376 KB
testcase_35 AC 6 ms
5,376 KB
testcase_36 AC 6 ms
5,376 KB
testcase_37 AC 4 ms
5,376 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 58 ms
9,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int N; cin>>N;
    vector<string> S(N);
    for(int i=0;i<N;i++) cin>>S[i];
    sort(S.begin(),S.end());
    int ans=0;
    vector<int>dp(26);
    for(int i=0;i<N;i++){
        for(int j=0;j+1<S[i].size();j++) if(S[i][j]>S[i][j+1]) goto home;
        dp[S[i].back()-'a']=max(dp[S[i].back()-'a'],dp[S[i].front()-'a']+(int)S[i].size());
        ans=max(ans,dp[S[i].back()-'a']);
        home:;
    }
    cout<<ans<<endl;
}
0