제출 #864439

#제출 시각아이디문제언어결과실행 시간메모리
864439VN_AnhTuanStove (JOI18_stove)C++14
100 / 100
471 ms5028 KiB
#include <bits/stdc++.h> #define fi first #define se second #define pii pair<int, int> #define mp make_pair #define pb push_back #define bit(X,i) ((X>>i)&1) #define fori(i,d,c) for(int i = d; i <= c; ++ i) #define ford(i,d,c) for(int i = d; i >= c; -- i) #define all(V) V.begin(), V.end() #define RRH(V) V.resize(unique(all(V))-V.begin()) #define debug(x) { cerr << #x << " = "; cerr << (x) << '\n'; } #define open(Task) if (fopen(Task".inp", "r")) {freopen(Task".inp", "r", stdin);freopen(Task".out", "w", stdout);} using namespace std; using ll = long long; using ld = long double; const int maxn = 1e5 + 5; const int maxm = 1e5 + 5; const int base = 101; int n, m, a[maxn]; void read() { cin >> n >> m; m --; fori(i,1,n) cin >> a[i]; } void solve() { priority_queue<int> pq; fori(i,2,n) { pq.push(max(0,a[i] - (a[i-1] + 1))); debug(a[i] - (a[i-1] + 1)); } int res = a[n] - a[1] + 1; while(m --> 0 && !pq.empty()) { res -= pq.top(); pq.pop(); } cout << res; } int main () { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); open("stove"); read(); solve(); return 0; }

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

stove.cpp: In function 'int main()':
stove.cpp:14:56: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 | #define open(Task) if (fopen(Task".inp", "r")) {freopen(Task".inp", "r", stdin);freopen(Task".out", "w", stdout);}
      |                                                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:47:5: note: in expansion of macro 'open'
   47 |     open("stove");
      |     ^~~~
stove.cpp:14:88: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 | #define open(Task) if (fopen(Task".inp", "r")) {freopen(Task".inp", "r", stdin);freopen(Task".out", "w", stdout);}
      |                                                                                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:47:5: note: in expansion of macro 'open'
   47 |     open("stove");
      |     ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...