結果

問題 No.1512 作文
ユーザー auauaauaua
提出日時 2021-05-21 22:52:49
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 1,204 bytes
コンパイル時間 2,240 ms
コンパイル使用メモリ 175,068 KB
実行使用メモリ 10,064 KB
最終ジャッジ日時 2024-04-18 16:20:16
合計ジャッジ時間 3,031 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 28 ms
7,376 KB
testcase_05 AC 25 ms
6,944 KB
testcase_06 AC 25 ms
6,992 KB
testcase_07 AC 25 ms
6,944 KB
testcase_08 AC 27 ms
7,120 KB
testcase_09 AC 5 ms
6,944 KB
testcase_10 AC 5 ms
6,944 KB
testcase_11 AC 4 ms
6,944 KB
testcase_12 AC 4 ms
6,944 KB
testcase_13 AC 5 ms
6,940 KB
testcase_14 AC 7 ms
6,940 KB
testcase_15 AC 7 ms
6,944 KB
testcase_16 AC 7 ms
6,940 KB
testcase_17 AC 8 ms
6,944 KB
testcase_18 AC 7 ms
6,940 KB
testcase_19 AC 6 ms
6,940 KB
testcase_20 AC 7 ms
6,940 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 1 ms
6,944 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 1 ms
6,944 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 1 ms
6,944 KB
testcase_29 AC 2 ms
6,944 KB
testcase_30 AC 1 ms
6,940 KB
testcase_31 AC 1 ms
6,944 KB
testcase_32 AC 1 ms
6,940 KB
testcase_33 AC 2 ms
6,940 KB
testcase_34 AC 2 ms
6,944 KB
testcase_35 AC 5 ms
6,940 KB
testcase_36 AC 5 ms
6,940 KB
testcase_37 AC 4 ms
6,940 KB
testcase_38 AC 5 ms
6,940 KB
testcase_39 AC 5 ms
6,940 KB
testcase_40 AC 35 ms
9,936 KB
testcase_41 AC 30 ms
10,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
//#define vec vector<ll>
//#define mat vector<vector<ll> >
#define fi first
#define se second
#define double long double
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
//typedef long double ld;
typedef complex<double> Complex;
const ll INF=1e9+7;
const ll MOD=998244353;
const ll inf=INF*INF;
const ll mod=INF;
const ll MAX=100010;




signed main(){
    ll n;cin>>n;
    vector<pair<pll,ll> >s(0);
    rep(i,n){
        string t;cin>>t;
        bool f=1;
        REP(i,1,t.size()){
            if(t[i]<t[i-1])f=0;
        }
        if(f){
            s.pb(mp(mp(t[0]-'a',t[t.size()-1]-'a'),t.size()));
        }
    }
    sort(all(s));
    vector<ll>dp(27);
    dp[0]=0;
    ll j=0;
    rep(i,27){
        if(i)dp[i]=max(dp[i-1],dp[i]);
        while(j<s.size()&&s[j].fi.fi==i){
            dp[s[j].fi.se]=max(dp[s[j].fi.se],dp[i]+s[j].se);
            j++;
        }
    }
    cout<<dp[26]<<endl;
}
0