## ๐[31027 - ๋ฌผ๊ณ ๊ธฐ ๊ฒ์](https://www.acmicpc.net/problem/31027)
#### ๐ KeyPoint
- ์ด ๋ฌธ์ ๋ '๊ฒ์ ์ด๋ก '์ ์ ์ฉํ๋ ๋ฌธ์ ์ด๋ค.
- 2 x n ํฌ๊ธฐ์ ๊ฒฉ์ํ์์ ์คํ ๊ฐ (1,1) ๋ฐ์ด๋ธ๊ฐ (2, n)์์ ์์์ ๋ ๋ ๋ค ์ต๋ํ ๋ง์ ๋ฌผ๊ณ ๊ธฐ๋ฅผ ์ป์๋ ค๊ณ ํ ๋ ๊ฐ์ ๋ช ๋ง๋ฆฌ๋ฅผ ์ป์ ์ ์๋๊ฐ๋ฅผ ๊ตฌํด์ผ ํ๋ค.
- ๊ฒฉ์ ํฌ๊ธฐ, ๋ฌผ๊ณ ๊ธฐ์ ์์ ๋ฐ๋ผ์ ๊ฐ์ ์ป๊ณ ์ ํ๋ ๊ฒฉ์ํ์ด ๋ฌ๋ผ์ง๊ธฐ ๋๋ฌธ์ ์ด๋ฅผ ๊ณ ๋ คํ๋๊ฒ ์ด ๋ฌธ์ ์ ํต์ฌ์ด๋ค.
- ์คํ ๊ฐ ๋จผ์ ์์ง์ด๊ธฐ ๋๋ฌธ์ ์ด ๋ํ ๊ณ ๋ คํ์ฌ์ผ ํ๋ค.
#### ๐ผ๏ธ๊ทธ๋ฆผ์ผ๋ก ์ดํดํ๊ธฐ
![[Fish Game.svg]]
#### โจ๏ธ Code
```cpp
#include <bits/stdc++.h>
using namespace std;
int n, farm[3][500001];
long long total = 0, otto_CaseA = 0, otto_CaseB = 0, david_CaseA = 0, david_CaseB = 0;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
cin >> n;
for ( int i = 1; i <= 2; i++ ) {
for ( int j = 1; j <= n; j++ ) {
cin >> farm[i][j];
total += farm[i][j];
}
}
if ( n == 2 ) {
cout << max(farm[1][2],farm[2][1]) << ' ' << total - max(farm[1][2],farm[2][1]);
} else {
if ( n % 2 == 0 ) {
for ( int i = 1; i <= n; i++ ) david_CaseA += farm[2][i];
for ( int i = 1; i <= 2; i++ ) {
for ( int j = (n/2) + 2; j <= n; j++ ) david_CaseB += farm[i][j];
}
if ( david_CaseA >= david_CaseB ) {
for ( int i = 1; i <= n; i++ ) otto_CaseA += farm[1][i];
for ( int i = 1; i <= 2; i++ ) {
for ( int j = 1; j <= (n/2); j++ ) otto_CaseB += farm[i][j];
}
if ( otto_CaseA > otto_CaseB ) cout << otto_CaseA << ' ' << total - otto_CaseA;
else cout << otto_CaseB << ' ' << total - otto_CaseB;
} else cout << total - david_CaseB << ' ' << david_CaseB;
} else {
for ( int i = 1; i <= n; i++ ) otto_CaseA += farm[1][i];
for ( int i = 1; i <= 2; i++ ) {
for ( int j = 1; j <= (n/2); j++ ) otto_CaseB += farm[i][j];
}
if ( otto_CaseA >= otto_CaseB ) {
for ( int i = 1; i <= n; i++ ) david_CaseA += farm[2][i];
for ( int i = 1; i <= 2; i++ ) {
for ( int j = (n/2) + 2; j <= n; j++ ) david_CaseB += farm[i][j];
}
if ( david_CaseA > david_CaseB ) cout << total - david_CaseA << ' ' << david_CaseA;
else cout << total - david_CaseB << ' ' << david_CaseB;
} else cout << otto_CaseB << ' ' << total - otto_CaseB;
}
}
return 0;
}
```
## ๐[20529 - ๊ฐ์ฅ ๊ฐ๊น์ด ์ธ ์ฌ๋์ ์ฌ๋ฆฌ์ ๊ฑฐ๋ฆฌ](https://www.acmicpc.net/problem/20529)