## ๐Ÿ“‘[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)