Submission #102597

# Submission time Handle Problem Language Result Execution time Memory
102597 2019-03-26T05:54:10 Z AbduM K blocks (IZhO14_blocks) C++14
0 / 100
5 ms 512 KB
/// In the name of GOD
/// I love my MOTHER
/// Only GOLD

#include <bits/stdc++.h>

#define all(x)                  x.begin(), x.end()
#define sz(s)                   (ll)(s.size())
#define pb                      push_back
#define pf                      push_front
#define ppb                     pop_back()
#define ppf                     pop_front()
#define F                       first
#define S                       second
#define MP                      make_pair
#define ort1                    exit(0);
#define nl                      "\n"

#define rep(i, l, r)            for(int i = (l); i <= (r); ++i)
#define per(i, l, r)            for(int i = (l); i >= (r); i--)
#define TL                      clock() / (double)CLOCKS_PER_SEC
#define NFS                     ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const double pi = acos(-1.0);
const double eps = 1e-7;
const long long inf = 1e12 + 1;
const long long INF = 1e18 + 1;
const int mod = 1e9 + 7;
const int N = 1e5 + 7;

int n, k;
ll a[N];
ll ans;

int main(){
    #ifdef ioi
        freopen("in.txt", "r", stdin);
    #endif // ioi
    NFS

    cin >> n >> k;

    if(k == 0){
        cout << 0;
        ort1
    }
    if(k == 1){
        cout << a[n];
        ort1
    }

    rep(i, 1, n){
        cin >> a[i];
    }
    sort(a + 1, a + 1 + n);
    rep(i, 1, k - 1){
        ans += a[i];
    }
    ans += a[n];

    cout << ans;

    #ifdef ioi
        cout << nl << TL << nl;
    #endif // ioi
    ort1
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -