답안 #825069

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
825069 2023-08-14T14:11:37 Z tpd2k Stove (JOI18_stove) C++14
100 / 100
18 ms 2876 KB
// teddybear's code
// the one who loves NBP
// noe the second
// goal: 0 / 8
// get medal in APIO (like TKN)
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")

// prob: 
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#define FOR(i,n) for (int i = 0; i<n; i++)
using ll = long long;
using ull = unsigned long long;
ll n,m,t;
ll cnt = 0;
const int maxn = 1e5;
const ll mod = 1e9 + 7;
#define Y "YES"
#define N "NO"
ll a[2 * maxn + 5];
bool visited[1005][1005];
int dist[1005][1005];
int w,h;
int fx[4] = {-1, 1, 0, 0};
int fy[4] = {0, 0, -1, 1};
queue <pair<int,int>> q;
ll dis[2 * maxn + 5];

void solve()
{
	cin >> n >> m;
	for (int i = 1; i<=n; i++)
	{
		cin >> a[i];
	}
	/*if (n == m)
	{
		cout << n;
		return;
	}*/
	
	ll total_time = a[n] - a[1] + 1;
	
	for (int i = 1; i<=n-1; i++)
	{
		dis[i] = a[i+1] - a[i] - 1;
	}
	sort(dis+1,dis+n, greater<ll>());
	
	for (int i = 1; i<m; i++)
	{
		total_time -= dis[i];
	}
	cout << total_time;
	
}

void init()
{
 	int te = 1; //cin >> te;
 	while (te--)
 	{
 	 	  solve();
 	}
}

void preprocess()
{

}


int main()
{
 	ios_base::sync_with_stdio(false);
 	cin.tie(NULL);
    //cin.tie(0); cout.tie(0);
    //freopen(".inp", "r", stdin);
    //freopen(".out", "w", stdout);
 	init();
 	preprocess();
 	//solve();
 	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 340 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 352 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 340 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 352 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 15 ms 2780 KB Output is correct
17 Correct 14 ms 2812 KB Output is correct
18 Correct 16 ms 2744 KB Output is correct
19 Correct 14 ms 2772 KB Output is correct
20 Correct 14 ms 2796 KB Output is correct
21 Correct 18 ms 2876 KB Output is correct
22 Correct 14 ms 2800 KB Output is correct
23 Correct 15 ms 2744 KB Output is correct
24 Correct 15 ms 2756 KB Output is correct