제출 #709717

#제출 시각아이디문제언어결과실행 시간메모리
709717DarkMatterStove (JOI18_stove)C++17
100 / 100
29 ms2304 KiB
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int>pi;
typedef pair<ll, ll>pl;
typedef vector<pi>vpi;
typedef vector<pl>vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
const long double PI = acos(-1);
const int oo = 2e9;
const int MOD = 998244353;
const int N = 2e5 + 7;
#define endl '\n'
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define read(v) for (auto& it : v) scanf("%d", &it);
#define readL(v) for (auto& it : v) scanf("%lld", &it);
#define print(v) for (auto it : v) printf("%d ", it); puts("");
#define printL(v) for (auto it : v) printf("%lld ", it); puts("");
void solve() {
	int n, k;
	scanf("%d %d", &n, &k);
	vi v(n), dif;
	read(v);
	for (int i = 1; i < n; i++)
		dif.push_back(v[i] - v[i - 1] - 1);
	ll ans = n;
	sort(all(dif));
	for (int i = 0; i < n - k; i++)
		ans += dif[i];
	printf("%lld\n", ans);
}
int t = 1;
int main() {
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt", "r", stdin);
	//#endif
		//scanf("%d", &t);
	while (t--) solve();
}

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

stove.cpp: In function 'void solve()':
stove.cpp:29:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |  scanf("%d %d", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~
stove.cpp:23:41: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 | #define read(v) for (auto& it : v) scanf("%d", &it);
      |                                    ~~~~~^~~~~~~~~~~
stove.cpp:31:2: note: in expansion of macro 'read'
   31 |  read(v);
      |  ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...