Submission #28284

#TimeUsernameProblemLanguageResultExecution timeMemory
28284점수판에 아이디와 팀명이 같이 표기되니, 신중하게 적어주세요. (#68)Wine Tasting (FXCUP2_wine)C++14
1 / 1
113 ms3192 KiB
#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)

wine.cpp: In function 'int main()':
wine.cpp:22:44: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0; i<N; i++) scanf("%d", &Nr[i]);
                                            ^
#Verdict Execution timeMemoryGrader output
Fetching results...