Skip to content

Instantly share code, notes, and snippets.

@Luzhiled Luzhiled/ARC075-C.cpp
Last active Jun 4, 2017

Embed
What would you like to do?
ARC075-C
#include <bits/stdc++.h>
using namespace std;
#define fs first
#define se second
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back
using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;
const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ")
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }
int n;
vi S;
int dp[110][101010];
int dfs(int i = 0, int s = 0) {
if (i == n) {
if (s % 10 == 0) {
return 0;
}
return s;
}
int &ret = dp[i][s];
if (ret != -1) return ret;
ret = 0;
ret = max(dfs(i + 1, s + S[i]), dfs(i + 1, s));
return ret;
}
int main() {
n = in();
rep(i, n) S.pb(in());
memset(dp, -1, sizeof(dp));
cout << dfs() << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.