結果
| 問題 | No.3289 Make More Happy Connection | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-10-03 21:42:41 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,999 bytes | 
| コンパイル時間 | 2,947 ms | 
| コンパイル使用メモリ | 280,536 KB | 
| 実行使用メモリ | 7,716 KB | 
| 最終ジャッジ日時 | 2025-10-03 21:42:52 | 
| 合計ジャッジ時間 | 5,671 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 23 WA * 1 | 
ソースコード
// #include <bits/allocator.h> // Temp fix for gcc13 global pragma
// #pragma GCC target("avx2,bmi2,popcnt,lzcnt")
// #pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
// #include <x86intrin.h>
using namespace std;
using namespace numbers;
#ifdef LOCAL
	#include "Debug.h"
#else
	#define debug_endl() 42
	#define debug(...) 42
	#define debug2(...) 42
	#define debug_bin(...) 42
#endif
// Returns the largest integer k with x >= k * y
template<class T, class U> U floor_div(T x, U y){
	assert(y > 0);
	return x / y - (x % y < 0);
}
// Returns the smallest integer k with x <= k * y
template<class T, class U> U ceil_div(T x, U y){
	assert(y > 0);
	return x / y + (x % y > 0);
}
template<class T> T &ctmin(T &x){ return x; }
template<class T, class Head, class ...Tail> T &ctmin(T &x, const Head &h, const Tail &... t){ return ctmin(x = min<T>(x, h), t...); }
template<class T> T &ctmax(T &x){ return x; }
template<class T, class Head, class ...Tail> T &ctmax(T &x, const Head &h, const Tail &... t){ return ctmax(x = max<T>(x, h), t...); }
// std::chunk_by cuz AtCoder is stuck on 3 years old gcc
vector<vector<int>> chunk_by(auto data, auto eq){
	vector<vector<int>> chunks;
	for(auto l = data.begin(); l != data.end(); ){
		auto r = next(l);
		vector<int> chunk{*l};
		while(r != data.end() && eq(*prev(r), *r)){
			chunk.push_back(*r);
			r = next(r);
		}
		chunks.push_back(chunk);
		l = r;
	}
	return chunks;
}
int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(ios::badbit | ios::failbit);
	int n;
	cin >> n;
	vector<array<int, 2>> a(n);
	for(auto &[x, y]: a){
		cin >> x >> y;
	}
	array<long long, 2> dp{};
	for(auto i = 1; i < n; ++ i){
		int extra = a[i][0] == a[i][1] ? a[i][0] : 0;
		dp = {
			max(dp[0] + a[i][1] * (a[i - 1][0] == a[i][1]), dp[1] + a[i][1] * (a[i - 1][1] == a[i][1])) + extra,
			max(dp[0] + a[i][0] * (a[i - 1][0] == a[i][0]), dp[1] + a[i][0] * (a[i - 1][1] == a[i][0])) + extra
		};
	}
	cout << ranges::max(dp) << "\n";
	return 0;
}
/*
*/
            
            
            
        