結果
| 問題 | 
                            No.1512 作文
                             | 
                    
| コンテスト | |
| ユーザー | 
                             milanis48663220
                         | 
                    
| 提出日時 | 2021-05-21 21:27:41 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,262 bytes | 
| コンパイル時間 | 1,067 ms | 
| コンパイル使用メモリ | 115,752 KB | 
| 最終ジャッジ日時 | 2025-01-21 14:17:47 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 21 WA * 17 | 
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>
#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
bool ok(string s){
    int m = s.size();
    for(int i = 1; i < m; i++){
        if(s[i] < s[i-1]) return false;
    }
    return true;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int n; cin >> n;
    vector<int> dp(26);
    for(int i = 0; i < n; i++){
        string s; cin >> s;
        if(!ok(s)) continue;
        int l = s[0]-'a';
        int r = s.back()-'a';
        for(int j = 25; j >= 0; j--){
            if(j > l) continue;
            chmax(dp[r], dp[j]+(int)s.size());
        }
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
}
            
            
            
        
            
milanis48663220