Created
September 20, 2016 11:00
-
-
Save yurahuna/a887faae0edca0ecb74f8ee7d105fd59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
signed main() { | |
std::ios::sync_with_stdio(false); | |
std::cin.tie(0); | |
int n; | |
cin >> n; | |
vi c(3); | |
rep(i, n) { | |
int a; | |
cin >> a; | |
c[a%3]++; | |
} | |
int ans = 1; | |
if (c[1] > 0) { | |
// 1から使うとき | |
int c1 = c[1], c2 = c[2]; | |
int t = c[0] + 1; c1--; | |
int x = min(c1, c2); | |
t += 2 * x; c1 -= x; c2 -= x; | |
t += max(min(c1, 2), min(c2, 1)); | |
ans = max(ans, t); | |
} | |
if (c[2] > 0) { | |
// 2から使うとき | |
int c1 = c[1], c2 = c[2]; | |
int t = c[0] + 1; c2--; | |
int x = min(c1, c2); | |
t += 2 * x; c1 -= x; c2 -= x; | |
t += max(min(c2, 2), min(c1, 1)); | |
ans = max(ans, t); | |
} | |
cout << ans << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment