제출 #41208

#제출 시각아이디문제언어결과실행 시간메모리
41208adletStove (JOI18_stove)C++14
100 / 100
63 ms1632 KiB
#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();
}

컴파일 시 표준 에러 (stderr) 메시지

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);
     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...