이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define forin(i,a,b) for(int i = a; i <= b;i++)
#define forde(i,a,b) for(int i = a; i >= b;i--)
#define re(i,a,b) for(int i = a; i < b; i++)
#define forv(a,b) for(auto & a : b)
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define fi first
#define se second
#define pb push_back
#define int long long
#define getbit(x,i) ((x >> i) & 1)
using namespace std;
const int N = 1e5 + 10;
int t[N],res[N-1];
int n,k,ans;
signed main()
{
cin.tie(0) -> sync_with_stdio(0);
if(fopen("task.cpp","r"))
{
freopen("task.cpp","r",stdin);
freopen("wa.cpp","w",stdout);
}
cin >> n >> k;
k = n - k;
forin(i,1,n) cin >> t[i];
re(i,1,n) res[i] = t[i+1] - t[i] - 1;
sort(res + 1, res + n);
ans = n;
forin(i,1,k)
{
ans += res[i];
}
cout << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
stove.cpp: In function 'int main()':
stove.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
22 | freopen("task.cpp","r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
stove.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
23 | freopen("wa.cpp","w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |