제출 #1192802

#제출 시각아이디문제언어결과실행 시간메모리
1192802cbnhtmanhStove (JOI18_stove)C++20
100 / 100
16 ms1480 KiB
/* .=#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#=. .*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+ :%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% =%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%# .+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%= .*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%: :#%%%%%%%%%#=....-#:......-*%%*:......:**+++++++++++++#%%%#++++++++++++++%*+++++++++++++++%%%%%%#. -%%%%%%%%+:......+%#-.....:+#-......:*%#+++++++++++++++*%%*+++++++++++++*%+++++++++++++++*%%%%%%*. .=%%%%%%-.........#%%%-...+#-.......+%%%#+++++#####*+++++#%++++++########%%####*+++++#####%%%%%%%=. .*%%%%%%:........-%%%%%+-#=.......=%%%%%*+++++%%%%%#+++++%#+++++#%%%%%%%%%%%%%%++++++%%%%%%%%%%%%-. :#%%%%%%--*+.....+%%%%%%+........#%%%%%%++++++++++++++++%%*++++++++++++#%%%%%%%+++++*%%%%%%%%%%%#: .:%%%%%%%%%%=....:#%%%%+...........*%%%%#++++++++++++++++#%+++++++++++++#%%%%%%*+++++%%%%%%%%%%%%*: .-%%%%%%%%%#:....-%%%*..............=%%%++++++%%%%%%*++++**+++++#%%%%%%%%%%%%%%++++++%%%%%%%%%%%%+. .+%%%%%%%%%*.....+%#:......:*-.......=%#+++++*#####*+++++#*+++++########%%%%%%#+++++#%%%%%%%%%%%%=. .*%%%%%%%%%=....:+-.......+%%%+.......-#*+++++++++++++++##++++++++++++++*%%%%%*+++++%%%%%%%%%%%%%- .%%%%%%%%%%:............+%%%%%%#=.......#*+++++++++++*#%%#++++++++++++++#%%%%%*++++*%%%%%%%%%%%%#- -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#: +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*. #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%- +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*. .=#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#=. */ #include <bits/stdc++.h> #define fi(i, a, b) for( int i = a; i <= b; i++ ) #define fid(i, a, b) for( int i = a; i >= b; i-- ) #define getbit(x, i) ((x>>i)&1) #define ll long long #define pb push_back #define pii pair<int,int> #define pli pair<ll,int> #define pll pair<ll,ll> #define st first #define nd second #define mp make_pair #define HTManh "" #define maxn 100009 #define endl '\n' using namespace std; int test; int n, k; int a[100009]; priority_queue<int> pq; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); if (fopen(HTManh".inp", "r")) { freopen(HTManh".inp", "r", stdin); freopen(HTManh".out", "w", stdout); } cin >> n >> k; fi(i,1,n) cin >> a[i]; ll res = a[n]+1-a[1]; fi(i,1,n-1) { //cout << a[i+1]-a[i]-1 << endl; pq.push(a[i+1]-a[i]-1); } fi(i,1,k-1) { res -= pq.top(); pq.pop(); } cout << res << endl; }

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

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