답안 #41208

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
41208 2018-02-14T01:56:50 Z adlet Stove (JOI18_stove) C++14
100 / 100
63 ms 1632 KB
#include <bits/stdc++.h>

using namespace std;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx")

#define name "stove"
#define file(s) if(fopen(s".in", "r")) freopen(s".in","r",stdin), freopen(s".out","w",stdout);

typedef long long ll;

const int N = 1e5 + 5;

int ok = 1, n, k, mx;

int t[N];

vector < int > v;

int fast() {
    ll sum = 0;
    sort(v.rbegin(), v.rend());
    for (int i = 0; i < v.size(); ++i) {
        if (i < k - 1)
            sum += (v[i] + 1);
    }
    return (t[n] - t[1] + k) - sum;
}

int main() {
    file(name);
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> t[i];
        if (i > 1)
            v.push_back({t[i] - t[i - 1] - 1});
    }
    cout << fast();
}

Compilation message

stove.cpp:5:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #pragma comment(linker, "/stack:200000000")
 ^
stove.cpp: In function 'int fast()':
stove.cpp:25:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < v.size(); ++i) {
                       ^
stove.cpp: In function 'int main()':
stove.cpp:10:94: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
 #define file(s) if(fopen(s".in", "r")) freopen(s".in","r",stdin), freopen(s".out","w",stdout);
                                                                                              ^
stove.cpp:33:5: note: in expansion of macro 'file'
     file(name);
     ^
stove.cpp:10:94: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
 #define file(s) if(fopen(s".in", "r")) freopen(s".in","r",stdin), freopen(s".out","w",stdout);
                                                                                              ^
stove.cpp:33:5: note: in expansion of macro 'file'
     file(name);
     ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 1 ms 356 KB Output is correct
4 Correct 2 ms 404 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 2 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 1 ms 356 KB Output is correct
4 Correct 2 ms 404 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 2 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 3 ms 604 KB Output is correct
11 Correct 3 ms 604 KB Output is correct
12 Correct 3 ms 604 KB Output is correct
13 Correct 3 ms 604 KB Output is correct
14 Correct 3 ms 604 KB Output is correct
15 Correct 3 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 1 ms 356 KB Output is correct
4 Correct 2 ms 404 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 2 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 3 ms 604 KB Output is correct
11 Correct 3 ms 604 KB Output is correct
12 Correct 3 ms 604 KB Output is correct
13 Correct 3 ms 604 KB Output is correct
14 Correct 3 ms 604 KB Output is correct
15 Correct 3 ms 620 KB Output is correct
16 Correct 58 ms 1512 KB Output is correct
17 Correct 58 ms 1524 KB Output is correct
18 Correct 59 ms 1524 KB Output is correct
19 Correct 56 ms 1524 KB Output is correct
20 Correct 59 ms 1524 KB Output is correct
21 Correct 57 ms 1524 KB Output is correct
22 Correct 56 ms 1524 KB Output is correct
23 Correct 62 ms 1632 KB Output is correct
24 Correct 63 ms 1632 KB Output is correct