제출 #1261321

#제출 시각아이디문제언어결과실행 시간메모리
1261321phamducluongStove (JOI18_stove)C++20
100 / 100
24 ms1476 KiB
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //using namespace __gnu_pbds; using namespace std; using ll=long long; //typedef tree<int,null_type,less_equal<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set; #define mem(a,x) memset(a,x,sizeof(a)) #define fast(s) s.reserve(2000); s.max_load_factor(0.5); #define F first #define S second #define pii pair <int, int> #define iii tuple<int,int,int> #define all(p) p.begin(), p.end() template<typename T> bool maximum(T &A, const T &B) {return A<B? A=B, true: false;} template<typename T> bool minimum(T &A, const T &B) {return A>B? A=B, true: false;} const int mod=1e9+7; const int base=2999; const int INF=1e9; const int N=1e5+5, LOG=17; int n, k, a[N], res; priority_queue<int,vector<int>,greater<int>> q; void file() { #define task "main" if(fopen(task".inp","r")) { freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } void Solve() { cin>>n>>k; for(int i=1; i<=n; ++i) cin>>a[i]; for(int i=2; i<=n; ++i) q.push(a[i]-a[i-1]-1); res=n; while((int)q.size()>=k) { res+=q.top(); q.pop(); } cout<<res; } signed main() { file(); Solve(); return 0; }

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

stove.cpp: In function 'void file()':
stove.cpp:28:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
stove.cpp:29:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         freopen(task".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...