結果

問題 No.3289 Make More Happy Connection
ユーザー GOTKAKO
提出日時 2025-10-03 21:34:55
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 531 bytes
コンパイル時間 1,533 ms
コンパイル使用メモリ 194,740 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-10-03 21:35:00
合計ジャッジ時間 4,128 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int N; cin >> N;
    long long bx = 0,vx = 0,by = 0,vy = 0;
    while(N--){
        long long x,y; cin >> x >> y;
        long long nx = max(vx,vy),ny = max(vx,vy);
        if(x == bx) ny = max(ny,vx+x);
        if(x == by) ny = max(ny,vy+x);
        if(y == bx) nx = max(nx,vx+y);
        if(y == by) nx = max(nx,vy+y);
        bx = x,by = y,vx = nx,vy = ny;
    }
    cout << max(vx,vy) << endl;
}   
0