結果
| 問題 |
No.1368 サイクルの中に眠る門松列
|
| コンテスト | |
| ユーザー |
mmn15277198
|
| 提出日時 | 2021-01-30 18:45:26 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 935 bytes |
| コンパイル時間 | 998 ms |
| コンパイル使用メモリ | 74,864 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-28 06:27:10 |
| 合計ジャッジ時間 | 2,257 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 WA * 11 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int f(int a , int b , int c){
if(a == b || b == c || c == a){
return 0;
}
if(b < a && b < c){
return a;
}
if(b > a && b > c){
return a;
}
return 0;
}
void solve(){
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
for(int i = 0; i < n % 3 + 2; i++){
a.push_back(a[i]);
}
long long res = 0;
long long cost0 = 0 , cost1 = 0 , cost2 = 0;
for (int i = 0; i < n; i++) {
if(i % 3 == 0)cost0 += f(a[i] , a[i + 1] , a[i + 2]);
if(i % 3 == 1)cost1 += f(a[i] , a[i + 1] , a[i + 2]);
if(i % 3 == 2)cost2 += f(a[i] , a[i + 1] , a[i + 2]);
}
res = max({cost0 , cost1 , cost2});
cout << res << endl;
}
int main() {
int t;
cin >> t;
while(t--){
solve();
}
return 0;
}
mmn15277198