Problem p03207 (C++)

Buggy submission (status: Runtime Error):
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

#define ll long long
#define pb push_back
#define pii pair<ll, ll>
#define vi vector<ll>
#define vii vector<pii>
#define mi map<int, int>
#define mii map<pii, int>
#define all(a) (a).begin(), (a).end()
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define endl '\n'
#define hell 1000000007
#define rep(i, a, b) for (int i = a; i < b; i++)
// mp::cpp_int

int solve() {

  int n;
  vi a(n);
  rep(i, 0, n) cin >> a[i];
  sort(all(a));
  int sum = 0;
  rep(i, 0, n) sum += a[i];
  cout << sum - a[n - 1] + a[n - 1] / 2;

  return 0;
}
int main() {
  int t = 1;
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  clock_t time_req;

  // Without using pow function
  time_req = clock();

  // cin>>t;
  while (t--) {
    solve();
  }

  time_req = clock() - time_req;
  // cout << "Processor time taken is "
  // << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;

  return 0;
}


Fixed submission:
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

#define ll long long
#define pb push_back
#define pii pair<ll, ll>
#define vi vector<ll>
#define vii vector<pii>
#define mi map<int, int>
#define mii map<pii, int>
#define all(a) (a).begin(), (a).end()
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define endl '\n'
#define hell 1000000007
#define rep(i, a, b) for (int i = a; i < b; i++)
// mp::cpp_int

int solve() {

  int n;
  cin >> n;
  vi a(n);
  rep(i, 0, n) cin >> a[i];
  sort(all(a));
  int sum = 0;
  rep(i, 0, n) sum += a[i];
  cout << sum - a[n - 1] + a[n - 1] / 2;

  return 0;
}
int main() {
  int t = 1;
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  clock_t time_req;

  // Without using pow function
  time_req = clock();

  // cin>>t;
  while (t--) {
    solve();
  }

  time_req = clock() - time_req;
  // cout << "Processor time taken is "
  // << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;

  return 0;
}