ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1025. Democracy in Danger

Why wrong answer?
Posted by Alexander 4 Oct 2019 22:16
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
 int a;
 int n;
 cin >> n;
 vector<int> v;
 for (int i = 0; i < n; i++) {
  cin >> a;
  v.push_back(a);
 }
 n = 0;
 sort(v.rbegin(), v.rend());
 for (int i = v.size()-1; i > (v.size()-2) / 2; i--)
  n += (v[i]+1)/2;
 cout << n << endl;
}
Re: Why wrong answer?
Posted by samio 21 Feb 2020 01:55
You should iterate from v.begin to v.end. No the reverse way.