답안 #760933

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
760933 2023-06-18T23:37:17 Z midi Stove (JOI18_stove) C++14
100 / 100
18 ms 2356 KB
#include <bits/stdc++.h>
using namespace std;
	
typedef long long ll;
typedef vector<ll> vcll;
typedef vector<int> vci;
typedef pair<ll, ll> prll;
typedef pair<int, int> prii;
	
#define f0r(i, a, n) for (i = a; i < (n); i++)
#define f1r(i, a, n) for (i = a; i <= (n); i++)
#define r0f(i, n, a) for (i = n; i > (a); i--)
#define r1f(i, n, a) for (i = n; i >= (a); i--)
	
#define pb push_back
#define all(item) item.begin(), item.end()
	
#define mxN 100'010
	
ll n, m;
	
vcll diff_ar;

inline void take_input()
{
	scanf("%lli %lli", &n, &m);
	ll last;
	scanf("%lli", &last);
	n--;
	ll i;

	f0r(i, 0, n)
	{
		ll t;
		// printf("i: %lli, n: %lli\n", i, n);
		scanf("%lli", &t);
		last++;

		// printf("t: %lli, last: %lli\n", t, last);

		diff_ar.pb(t - last);
		// printf("put value on %lli : %lli\n", i, t - last);
		last = t;
	}

	// sort(all(diff_ar));
	sort(diff_ar.begin(), diff_ar.end());
	// for (auto const &v : diff_ar) printf("v: %lli\n", v);
}

inline void give_output()
{
	ll i;
	ll sum = 0;
	n++;

	// printf("n - m: %lli\n", n - m);
	// printf("diff_ar[0]: %lli\n", diff_ar[0]);
	f0r(i, 0, n - m)
		sum += diff_ar[i];

	// printf("sum: %lli\n", sum);
	printf("%lli\n", sum + n);
}

int main()
{
	take_input();
	give_output();
	
	return 0;
}

Compilation message

stove.cpp: In function 'void take_input()':
stove.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  scanf("%lli %lli", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~
stove.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |  scanf("%lli", &last);
      |  ~~~~~^~~~~~~~~~~~~~~
stove.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |   scanf("%lli", &t);
      |   ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 352 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 352 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 15 ms 2352 KB Output is correct
17 Correct 15 ms 2356 KB Output is correct
18 Correct 15 ms 2224 KB Output is correct
19 Correct 18 ms 2252 KB Output is correct
20 Correct 15 ms 2252 KB Output is correct
21 Correct 15 ms 2252 KB Output is correct
22 Correct 16 ms 2272 KB Output is correct
23 Correct 15 ms 2352 KB Output is correct
24 Correct 15 ms 2252 KB Output is correct