結果
| 問題 |
No.1512 作文
|
| コンテスト | |
| ユーザー |
milanis48663220
|
| 提出日時 | 2021-05-21 21:28:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,305 bytes |
| コンパイル時間 | 1,238 ms |
| コンパイル使用メモリ | 116,456 KB |
| 最終ジャッジ日時 | 2025-01-21 14:20:33 |
|
ジャッジサーバーID (参考情報) |
judge4 / 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';
int mx = 0;
for(int j = 25; j >= 0; j--){
if(j > l) continue;
chmax(mx, dp[j]);
}
chmax(dp[r], mx+(int)s.size());
}
cout << *max_element(dp.begin(), dp.end()) << endl;
}
milanis48663220