# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28284 | 점수판에 아이디와 팀명이 같이 표기되니, 신중하게 적어주세요. (#68) | Wine Tasting (FXCUP2_wine) | C++14 | 113 ms | 3192 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi; typedef pair<ll, int> pli; typedef pair<ll, pi> plp;
typedef tuple<int, int, int> ti; typedef tuple<ll, int, int> tli;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;
const int MAX_N = 3e5 + 100;
int N, K, Nr[MAX_N];
int main() {
cin >> N >> K;
for(int i=0; i<N; i++) scanf("%d", &Nr[i]);
sort(Nr, Nr+N);
int l = 0, r = N-1, last = 0;
ll ans = 0;
for(int i=0; i<K; i++) {
if(i % 2 == 0) {
ans += Nr[r] - last;
last = Nr[r]; r--;
} else {
ans += 0;
last = Nr[l]; l++;
}
}
printf("%lld\n", ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |