Submission #28291

# Submission time Handle Problem Language Result Execution time Memory
28291 2017-07-16T04:27:06 Z 三( ε:)(#1146, xdoju, veckal, unused) Wine Tasting (FXCUP2_wine) C++14
1 / 1
109 ms 9420 KB
#include <bits/stdc++.h>
using namespace std;

int t[300005];
vector<int> vt;

int main()
{
    int n, k;
    scanf("%d%d",&n,&k);
    for (int i = 0; i < n; i++) scanf("%d",&t[i]);
    sort(t, t + n);
    for (int i = 0; i < n; i++)
    {
        vt.push_back(t[n - i - 1]);
        vt.push_back(t[i]);
    }

    long long ans = 0;
    int last = 0;
    for (int i = 0; i < k; i++)
    {
        ans += max(vt[i] - last, 0);
        last = vt[i];
    }
    printf("%lld\n", ans);
}

Compilation message

wine.cpp: In function 'int main()':
wine.cpp:10:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&k);
                        ^
wine.cpp:11:50: 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",&t[i]);
                                                  ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3192 KB Output is correct
2 Correct 0 ms 3192 KB Output is correct
3 Correct 0 ms 3192 KB Output is correct
4 Correct 0 ms 3192 KB Output is correct
5 Correct 0 ms 3192 KB Output is correct
6 Correct 0 ms 3192 KB Output is correct
7 Correct 0 ms 3192 KB Output is correct
8 Correct 0 ms 3192 KB Output is correct
9 Correct 0 ms 3192 KB Output is correct
10 Correct 0 ms 3192 KB Output is correct
11 Correct 0 ms 3192 KB Output is correct
12 Correct 0 ms 3192 KB Output is correct
13 Correct 0 ms 3332 KB Output is correct
14 Correct 0 ms 3332 KB Output is correct
15 Correct 0 ms 3332 KB Output is correct
16 Correct 0 ms 3332 KB Output is correct
17 Correct 3 ms 3660 KB Output is correct
18 Correct 6 ms 3660 KB Output is correct
19 Correct 6 ms 3660 KB Output is correct
20 Correct 6 ms 3660 KB Output is correct
21 Correct 16 ms 4812 KB Output is correct
22 Correct 33 ms 4812 KB Output is correct
23 Correct 23 ms 4812 KB Output is correct
24 Correct 29 ms 4812 KB Output is correct
25 Correct 86 ms 9420 KB Output is correct
26 Correct 83 ms 9420 KB Output is correct
27 Correct 83 ms 9420 KB Output is correct
28 Correct 53 ms 9420 KB Output is correct
29 Correct 83 ms 9420 KB Output is correct
30 Correct 89 ms 9420 KB Output is correct
31 Correct 93 ms 9420 KB Output is correct
32 Correct 109 ms 9420 KB Output is correct
33 Correct 0 ms 3192 KB Output is correct
34 Correct 16 ms 4812 KB Output is correct