253462026-02-19 12:10:14ubormaciBal-jobb játékcpp17Wrong answer 0/50160ms3736 KiB
#pragma GCC optimize("O2")
// #pragma GCC optimize("O1","O2","O3","Ofast","unroll-loops")
// #pragma GCC target("sse","sse2","sse3","sse4.1","sse4.2","avx","avx2","fma")

#include <iostream>
#include <algorithm> // for sort, mainly
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <array>
#include <string>
#include <cstdio>
#include <iterator>
#include <unordered_set>
#include <cstdint> // for int64_t, int32_t, etc
#include <queue>
#include <stack>
#include <deque>
#include <numeric> // gcd, lcm
#include <fstream>
#include <bitset> // for bitset
#include <iomanip>
#include <cassert> // for set with custom ordering
#include <type_traits> // for set with custom ordering
#include <utility> // for swap, forward, etc
using namespace std;

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cout << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << H; dbg_out(T...); }
#ifdef LOCAL
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

/*

notes:

int64_t
stoi(string s) -> string to int
to_string() -> int (or else) to string

vector declaration:
vector<ll> v(n, 0)
vector<vector<ll>> v(n, vector<ll>(n, 0));

{if statement} ? {truth value} : {false value}

#ifdef LOCAL
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif

std::lcm(ll a, ll b), std::gcd(int a, int b)

cout << fixed << setprecision(n);

set with custom ordering
set<ll, decltype(&cmp)> qu(cmp);

*/

typedef int64_t ll;

void getpoint(ll fst, ll n, ll len, vector<ll> &v) {

	for(ll i = fst-1; i > 0; i -= 2) {
		if(v[i] == -1) {
			cout << i;
			return;
		}
	}
	for(ll i = fst+1; i < len; i+=2) {
		if(v[i] == 1) {
			cout << i;
			return;
		}
	}
	for(ll i =1; i < len; i+=2) {
		if(i != fst - 1 && i != fst + 1) {
			cout << i;
			return;
		}
	}
}

void solve() {

	ll n;
	cin >> n;

	ll len = 2 * n - 1;

	vector<ll> v(len, 0);
	for(ll i = 0; i < len; i++) {
		if(i % 2 == 0) {
			cin >> v[i];
		}else{
			char h;
			cin >> h;
			if(h == 'J') {
				v[i] = 1;
			}else{
				v[i] = -1;
			}
		}
	}

	vector<ll> pref(len, 0);
	ll mn = 0;
	ll fst = 0;
	ll lst = 0;
	
	for(ll i = 2; i < len; i += 2) {
		pref[i] = pref[i-2] + v[i-1];
		if(pref[i] < mn) {
			mn = pref[i];
			fst = i;
			lst = i;
		}else if(pref[i] == mn) {
			lst = i;
		}
	}

	cerr << "\npref=" << pref;
	cerr << "\nfst=" << fst << "; lst=" << lst;

	ll res = max(v[fst], v[lst]);
	
	cout << res << "\n";
	
	ll pos = 0;
	if(res == v[fst]) {
		pos = fst;
	}else{
		pos = lst;
	}

	cerr << "\npos=" << pos;

	getpoint(pos, n, len, v);
}

int main()
{
	std::ios_base::sync_with_stdio(false);
	//cin.tie(nullptr);
	//cout.tie(nullptr);

	solve();

	return 0;
}

/*

Bevallom, erre nem magamtol jottem ra
megneztem a megoldast
https://tehetseg.inf.elte.hu/nemes/nemes_archivum.html

*/
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer1ms316 KiB
subtask20/4
2Wrong answer158ms3564 KiB
3Wrong answer158ms3632 KiB
4Wrong answer160ms3380 KiB
5Wrong answer158ms3572 KiB
6Wrong answer158ms3380 KiB
7Wrong answer158ms3380 KiB
subtask30/8
8Wrong answer1ms500 KiB
9Wrong answer158ms3380 KiB
10Wrong answer158ms3380 KiB
11Wrong answer158ms3572 KiB
12Wrong answer158ms3380 KiB
13Wrong answer159ms3380 KiB
14Wrong answer160ms3396 KiB
15Wrong answer159ms3380 KiB
16Wrong answer158ms3380 KiB
17Wrong answer158ms3416 KiB
18Wrong answer158ms3536 KiB
19Wrong answer156ms3380 KiB
20Wrong answer158ms3380 KiB
21Wrong answer158ms3376 KiB
22Wrong answer160ms3544 KiB
23Wrong answer160ms3380 KiB
24Wrong answer157ms3380 KiB
subtask40/14
25Wrong answer1ms500 KiB
26Wrong answer2ms316 KiB
27Wrong answer2ms508 KiB
28Wrong answer1ms508 KiB
29Wrong answer1ms316 KiB
30Wrong answer1ms316 KiB
31Wrong answer1ms316 KiB
32Wrong answer1ms316 KiB
33Wrong answer1ms316 KiB
34Wrong answer1ms316 KiB
35Wrong answer1ms316 KiB
36Wrong answer1ms316 KiB
37Wrong answer1ms316 KiB
38Wrong answer1ms316 KiB
39Wrong answer1ms336 KiB
40Wrong answer1ms316 KiB
41Wrong answer1ms316 KiB
42Wrong answer1ms316 KiB
43Wrong answer1ms316 KiB
44Wrong answer1ms316 KiB
45Wrong answer1ms316 KiB
46Wrong answer1ms316 KiB
47Wrong answer1ms384 KiB
48Wrong answer1ms316 KiB
49Wrong answer1ms316 KiB
50Wrong answer1ms316 KiB
51Wrong answer1ms316 KiB
52Wrong answer1ms316 KiB
53Wrong answer1ms316 KiB
54Wrong answer1ms316 KiB
55Wrong answer1ms316 KiB
56Wrong answer1ms316 KiB
57Wrong answer1ms324 KiB
58Wrong answer1ms372 KiB
59Wrong answer1ms316 KiB
60Wrong answer1ms316 KiB
61Wrong answer1ms508 KiB
62Wrong answer1ms316 KiB
63Wrong answer1ms316 KiB
64Wrong answer1ms316 KiB
65Wrong answer1ms316 KiB
66Wrong answer1ms316 KiB
67Wrong answer1ms316 KiB
68Wrong answer1ms316 KiB
69Wrong answer1ms316 KiB
70Wrong answer1ms316 KiB
subtask50/24
71Wrong answer1ms500 KiB
72Wrong answer158ms3564 KiB
73Wrong answer158ms3632 KiB
74Wrong answer160ms3380 KiB
75Wrong answer158ms3572 KiB
76Wrong answer158ms3380 KiB
77Wrong answer158ms3380 KiB
78Wrong answer158ms3380 KiB
79Wrong answer158ms3380 KiB
80Wrong answer158ms3572 KiB
81Wrong answer158ms3380 KiB
82Wrong answer159ms3380 KiB
83Wrong answer160ms3396 KiB
84Wrong answer159ms3380 KiB
85Wrong answer158ms3380 KiB
86Wrong answer158ms3416 KiB
87Wrong answer158ms3536 KiB
88Wrong answer156ms3380 KiB
89Wrong answer158ms3380 KiB
90Wrong answer158ms3376 KiB
91Wrong answer160ms3544 KiB
92Wrong answer160ms3380 KiB
93Wrong answer157ms3380 KiB
94Wrong answer2ms316 KiB
95Wrong answer2ms508 KiB
96Wrong answer1ms508 KiB
97Wrong answer1ms316 KiB
98Wrong answer1ms316 KiB
99Wrong answer1ms316 KiB
100Wrong answer1ms316 KiB
101Wrong answer1ms316 KiB
102Wrong answer1ms316 KiB
103Wrong answer1ms316 KiB
104Wrong answer1ms316 KiB
105Wrong answer1ms316 KiB
106Wrong answer1ms316 KiB
107Wrong answer1ms336 KiB
108Wrong answer1ms316 KiB
109Wrong answer1ms316 KiB
110Wrong answer1ms316 KiB
111Wrong answer1ms316 KiB
112Wrong answer1ms316 KiB
113Wrong answer1ms316 KiB
114Wrong answer1ms316 KiB
115Wrong answer1ms384 KiB
116Wrong answer1ms316 KiB
117Wrong answer1ms316 KiB
118Wrong answer1ms316 KiB
119Wrong answer1ms316 KiB
120Wrong answer1ms316 KiB
121Wrong answer1ms316 KiB
122Wrong answer1ms316 KiB
123Wrong answer1ms316 KiB
124Wrong answer1ms316 KiB
125Wrong answer1ms324 KiB
126Wrong answer1ms372 KiB
127Wrong answer1ms316 KiB
128Wrong answer1ms316 KiB
129Wrong answer1ms508 KiB
130Wrong answer1ms316 KiB
131Wrong answer1ms316 KiB
132Wrong answer1ms316 KiB
133Wrong answer1ms316 KiB
134Wrong answer1ms316 KiB
135Wrong answer1ms316 KiB
136Wrong answer1ms316 KiB
137Wrong answer1ms316 KiB
138Wrong answer1ms316 KiB
139Wrong answer156ms3536 KiB
140Wrong answer153ms3564 KiB
141Wrong answer155ms3380 KiB
142Wrong answer151ms3568 KiB
143Wrong answer151ms3380 KiB
144Wrong answer152ms3380 KiB
145Wrong answer157ms3736 KiB
146Wrong answer158ms3380 KiB
147Wrong answer158ms3376 KiB
148Wrong answer158ms3736 KiB
149Wrong answer158ms3380 KiB
150Wrong answer159ms3540 KiB
151Wrong answer155ms3380 KiB
152Wrong answer156ms3380 KiB
153Wrong answer155ms3564 KiB
154Wrong answer157ms3540 KiB
155Wrong answer159ms3380 KiB
156Wrong answer158ms3540 KiB
157Wrong answer153ms3380 KiB
158Wrong answer155ms3380 KiB
159Wrong answer155ms3580 KiB
160Wrong answer157ms3380 KiB
161Wrong answer158ms3380 KiB
162Wrong answer158ms3380 KiB
163Wrong answer158ms3380 KiB
164Wrong answer157ms3380 KiB
165Wrong answer158ms3564 KiB
166Wrong answer157ms3540 KiB
167Wrong answer158ms3380 KiB