Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
- const int M = 5;
- const int INF = 1e9 + 7;
- using namespace std;
- int calc_mn_sum(vector<int> &buf)
- {
- int mn_sum = INF;
- int mn[2] = {INF, INF};
- for(int i=0; i<(int)buf.size(); ++i)
- {
- mn_sum = min(mn_sum, mn[buf[i]%2] + buf[i]);
- mn[buf[i]%2] = min(mn[buf[i]%2], buf[i]);
- }
- return mn_sum;
- }
- int main()
- {
- #ifdef AZHUKOV
- freopen("input.txt", "r", stdin);
- #endif // AZHUKOV
- vector<int> buf;
- for(int i=0; i<M; ++i)
- {
- int x;
- cin >> x;
- buf.push_back(x);
- }
- int mn_sum = INF;
- for(int i=M; i<1000; ++i)
- {
- int x;
- cin >> x;
- buf.push_back(x);
- mn_sum = min(mn_sum, calc_mn_sum(buf));
- buf.erase(buf.begin());
- }
- cout << mn_sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement