Submission #35475170


Source Code Expand

Copy
//g++ -std=c++17 -Wl,--stack,268435456 Ahoyy.cpp -o Ahoyy.exe
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define pb push_back
#define fi first
#define se second
#define UP(a,b,c) for(ll (a)=(b);(a)<(c);++(a))
#define UU(a,b,c) for(ll (a)=(b);(a)<=(c);++(a))
#define DN(a,b,c) for(ll (a)=(b);(a)>(c);--(a))
#define DU(a,b,c) for(ll (a)=(b);(a)>=(c);--(a))
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//g++ -std=c++17 -Wl,--stack,268435456 Ahoyy.cpp -o Ahoyy.exe


#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define pb push_back
#define fi first
#define se second
#define UP(a,b,c) for(ll (a)=(b);(a)<(c);++(a))
#define UU(a,b,c) for(ll (a)=(b);(a)<=(c);++(a))
#define DN(a,b,c) for(ll (a)=(b);(a)>(c);--(a))
#define DU(a,b,c) for(ll (a)=(b);(a)>=(c);--(a))
#define lc(i) i+1
#define rc(i) i+(m-l+1)*2

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll expo(ll a, ll b, ll mod) {
	if(b == 0) return 1;
	if(b == 1) return a % mod;
	ll ret = expo(a, b>>1, mod);
	ret *= ret;
	if(ret >= mod) ret %= mod;
	if(b & 1) {
		ret *= a;
		if(ret >= mod) ret %= mod;
	}
	return ret;
}

ll inv(ll v, ll mod) {
	return expo(v, mod - 2, mod);
}

ll n;
vector<ll> a[2];

void reset() {
}

void input() {
	cin >> n;
	UU(i, 1, n) {
		ll x;
		cin >> x;
		a[x&1].pb(x);
	}
}

void solve() {
	sort(a[0].begin(), a[0].end());
	sort(a[1].begin(), a[1].end());
	ll ans = -1;

	if(a[0].size() > 1) {
		ans = a[0].back() + a[0][a[0].size() - 2];
	}

	if(a[1].size() > 1) {
		ans = max(ans, a[1].back() + a[1][a[1].size() - 2]);
	}

	cout << ans << endl;
}

void Ahoy() {
	solve();
}

int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	// freopen("in.txt", "r", stdin);
	// freopen("in.txt", "w", stdout);

	int TC = 1;
	// cin >> TC;
	UU(t, 1, TC) {
		// cout << "Case #" << t << ": ";
		input();
		Ahoy();
		reset();
	}

	return 0;
}

Submission Info

Submission Time
Task C - Max Even
User kresna
Language C++ (GCC 9.2.1)
Score 300
Code Size 2020 Byte
Status AC
Exec Time 42 ms
Memory 6152 KB

Compile Error

./Main.cpp: In function ‘void input()’:
./Main.cpp:19:26: warning: unnecessary parentheses in declaration of ‘i’ [-Wparentheses]
   19 | #define UU(a,b,c) for(ll (a)=(b);(a)<=(c);++(a))
      |                          ^
./Main.cpp:59:2: note: in expansion of macro ‘UU’
   59 |  UU(i, 1, n) {
      |  ^~
./Main.cpp: In function ‘int main()’:
./Main.cpp:19:26: warning: unnecessary parentheses in declaration of ‘t’ [-Wparentheses]
   19 | #define UU(a,b,c) for(ll (a)=(b);(a)<=(c);++(a))
      |                          ^
./Main.cpp:93:2: note: in expansion of macro ‘UU’
   93 |  UU(t, 1, TC) {
      |  ^~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 20
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt
All 00_sample_01.txt, 00_sample_02.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt, 02_handmade_05.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 7 ms 3536 KB
00_sample_02.txt AC 3 ms 3524 KB
01_test_01.txt AC 2 ms 3532 KB
01_test_02.txt AC 2 ms 3588 KB
01_test_03.txt AC 40 ms 6152 KB
01_test_04.txt AC 42 ms 5252 KB
01_test_05.txt AC 38 ms 5364 KB
01_test_06.txt AC 37 ms 5240 KB
01_test_07.txt AC 40 ms 5300 KB
01_test_08.txt AC 37 ms 5156 KB
01_test_09.txt AC 39 ms 5660 KB
01_test_10.txt AC 38 ms 5248 KB
01_test_11.txt AC 38 ms 5624 KB
01_test_12.txt AC 38 ms 4896 KB
01_test_13.txt AC 39 ms 5376 KB
02_handmade_01.txt AC 2 ms 3580 KB
02_handmade_02.txt AC 2 ms 3496 KB
02_handmade_03.txt AC 40 ms 5364 KB
02_handmade_04.txt AC 2 ms 3592 KB
02_handmade_05.txt AC 38 ms 5252 KB


2025-02-28 (Fri)
05:16:16 +00:00