Submission #1250620

#TimeUsernameProblemLanguageResultExecution timeMemory
1250620monaxiaAkcija (COCI15_akcija)C++20
80 / 80
11 ms1096 KiB
#include <bits/stdc++.h>
#include <ext/random>
#include <ext/pb_ds/assoc_container.hpp>

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC optimize ("Ofast")

#define pb push_back
#define ppb pop_back
#define fr first
#define sc second
#define all(v) v.begin(), v.end()
#define all1(v) v.begin() + 1, v.begin() + n + 1

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

constexpr ull Mod = 1e9 + 7;
constexpr ld eps = 1e-9;
constexpr int sqr = 447;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
long long random (long long l, long long r){if(l <= r) return uniform_int_distribution <long long> (l, r)(rng); return -1;}

void solve(){
    int n;
    ll ans = 0;
    cin >> n;

    vector <ll> a(n + 1, 0);

    for(int i = 1; i <= n; i ++) {
        cin >> a[i];
        ans += a[i];
    }

    sort(all1(a), greater <> ());


    for(int i = 3; i <= n; i += 3) ans -= a[i];

    cout << ans;
}   

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    if(fopen("TERRORIST.inp", "r")){
        freopen("TERRORIST.inp", "r", stdin);
        freopen("TERRORIST.out", "w", stdout);
    }

    // cout << 1; return 0;

    unsigned n = 1;
    // cin >> n;

    while(n) {
        solve();
        -- n;
        cout << "\n";
    }
 
    // cerr << "t elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}

Compilation message (stderr)

akcija.cpp: In function 'int main()':
akcija.cpp:55:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |         freopen("TERRORIST.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
akcija.cpp:56:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |         freopen("TERRORIST.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...