답안 #1104424

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1104424 2024-10-23T17:48:04 Z qrn Akcija (COCI15_akcija) C++14
80 / 80
14 ms 1276 KB
#include <bits/stdc++.h>
using namespace std;
 
template<class ISqr, class T>
ISqr& operator>>(ISqr& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
 
#define SPEED                     \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);                \
    cout.tie(NULL);
 
template <typename T>
void show(vector<T> &v) {
  for (T i : v) {
    cout << i << ' ';
  }
  cout << endl;
}

 
#define pb push_back
#define ins insert
#define fi first
#define se second
 
#define endl "\n"
#define ALL(x) x.begin(), x.end()
#define sz(x) x.size()
#define int long long
#define _ << " " <<
#define no cout << "No" << endl;
#define yes cout << "Yes" << endl;
#define impos cout << -1 << endl;
 
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
 
void solve() {
    // 4 5 5 5 5 6 6 
    // 1 2 3 4 5 6 7 8 9 10

    int n;
    cin >> n;
    vi a(n);
    cin >> a;
    
    int sum = 0;
    for(int i : a) sum += i;

    sort(ALL(a));
    reverse(ALL(a));
    int orz = 0;
    for(int i = 0; i < n; i++) {
        orz += ((i % 3 == 2) ? a[i] : 0);
    }
    cout << sum - orz << endl;
}
 
signed main(){
    SPEED;
    int t = 1;
    // cin >> t;
    for(int cs = 1; cs <= t; cs++) {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 9 ms 1104 KB Output is correct
7 Correct 11 ms 1104 KB Output is correct
8 Correct 8 ms 1276 KB Output is correct
9 Correct 13 ms 1104 KB Output is correct
10 Correct 14 ms 1104 KB Output is correct