제출 #1222161

#제출 시각아이디문제언어결과실행 시간메모리
1222161_Knyaz_Stove (JOI18_stove)C++20
100 / 100
13 ms1864 KiB
///Bismillahir Rohmanir Rohim #include <bits/stdc++.h> using namespace std; #define ff first #define sc second #define int int64_t #define ll __uint128_t #define sz(x) long((x).size()) #define all(x) (x).begin(), (x).end() const int mod = 1e9+7; const double PI = acos( -1. ); void in(){ freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); } void solve(){ int N, K, sum; cin >> N >> K; sum = N; vector<int> vec(N), pre(N-1); for(int i = 0; i < N; i++){ int T; cin >> T; vec[i] = T; } for(int i = 1; i < N; i++) pre[i-1] = vec[i] - vec[i-1] - 1; sort(all(pre)); for(int i = 0; i < N - K; i++) sum += pre[i]; cout << sum; } signed main(){ //in(); cin.tie(0)->sync_with_stdio(0); int t; t = 1; //cin >> t; while(t--) solve(); } /* ██╗ ██╗███╗ ██╗██╗ ██╗ █████╗ ███████╗ ██║ ██╔╝████╗ ██║╚██╗ ██╔╝██╔══██╗╚══███╔╝ █████╔╝ ██╔██╗ ██║ ╚████╔╝ ███████║ ███╔╝ ██╔═██╗ ██║╚██╗██║ ╚██╔╝ ██╔══██║ ███╔╝ ███████╗██║ ██╗██║ ╚████║ ██║ ██║ ██║███████╗███████╗ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝ */

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

stove.cpp: In function 'void in()':
stove.cpp:13:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     freopen("input.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:14:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     freopen("output.txt", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...