結果
問題 |
No.921 ずんだアロー
|
ユーザー |
|
提出日時 | 2019-11-08 21:51:56 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,499 bytes |
コンパイル時間 | 906 ms |
コンパイル使用メモリ | 89,840 KB |
実行使用メモリ | 7,300 KB |
最終ジャッジ日時 | 2024-09-15 01:25:32 |
合計ジャッジ時間 | 1,945 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 WA * 6 |
ソースコード
#include<iostream> #include<string> #include<iomanip> #include<cmath> #include<vector> #include<algorithm> #include<queue> using namespace std; #define int long long #define endl "\n" const long long INF = (long long)1e18; const long long MOD = 1'000'000'007; string yn(bool f){return f?"Yes":"No";} string YN(bool f){return f?"YES":"NO";} signed main(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(10); const int MAX = 110000; int N; int a = 0, b = 0; vector<int> A, used; vector<pair<int,int>> B; static int dp[MAX] = {}; priority_queue<pair<int,int>> Q; cin>>N; A.resize(N); used.resize(N+10); for(int i = 0; i < N; i++){ cin>>A[i]; if(B.size() == 0) B.push_back({1,A[i]}); else if(B.back().second == A[i]) B.back().first++; else B.push_back({1,A[i]}); } // for(int i = 0; i < B.size(); i++){ //cout<<i<<endl; // if(i%2) a += B[i].first; // else b += B[i].first; // } for(int i = 0; i < B.size(); i++){ // for(int ){ // } // Q.push(make_pair(B[i].first,i+1)); } // while(!Q.empty()){ // pair<int,int> P = Q.top(); Q.pop(); // int con = P.second; // if(used[con]) continue; // used[con+1] = true; // used[con] = true; // used[con-1] = true; // a += P.first; // } for(int i = 0; i < B.size(); i++){ dp[i+2] = max(dp[i+2], B[i].first+dp[i]); dp[i+1] = max(dp[i+1], dp[i]); a = max(dp[i], dp[i+1]); a = max(dp[i], dp[i+2]); } cout<<max(a,b)<<endl; return 0; }