Submission #915288

# Submission time Handle Problem Language Result Execution time Memory
915288 2024-01-23T15:52:00 Z jpfr12 Akcija (COCI15_akcija) C++14
16 / 80
13 ms 1628 KB
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
#include <climits>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
#include <fstream>
#include <bitset>
#include <iomanip>
 
typedef long long ll;
using namespace std;
int MOD = (int)1e9;
int MAXN = 1e6;
 
//classes

 
 
//global


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  //ifstream fin("input.txt");
  //ofstream fout("output.txt");
  //stop
  int n;
  cin >> n;
  vector<ll> vec(n);
  for(ll& i: vec) cin >> i;
  sort(vec.begin(), vec.end());
  int left = 0, right = n-1;
  ll sum = 0;
  while(right-left+1 >= 3){
    sum += vec[right] + vec[left+1];
    right--;
    left += 2;
  }
  if(right-left+1 == 2) sum += vec[right] + vec[left];
  else if(right-left+1 == 1) sum += vec[right];
  cout << sum << '\n';
  return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Incorrect 1 ms 344 KB Output isn't correct
6 Incorrect 10 ms 1624 KB Output isn't correct
7 Correct 6 ms 1628 KB Output is correct
8 Correct 7 ms 1628 KB Output is correct
9 Incorrect 12 ms 1628 KB Output isn't correct
10 Incorrect 13 ms 1628 KB Output isn't correct