답안 #1086007

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1086007 2024-09-09T09:33:52 Z Wendidiask Stove (JOI18_stove) C++14
100 / 100
35 ms 3332 KB
/*
                                     :---:--:--::::::--:-:----:                                     
                               ::-:::.                         ::-:::                               
                       .*  -===..                                    :---                           
                     .-+*##=-------====-:                                :--:                       
                  :+##=.* -=            :=+-                                .-=:                    
               .+++-.  :-   -=.            .=+-                                .--.                 
             .++=-     +      -=              :*-                                 :-.               
            +*+-      :-        -=.             -*:                                 :=:             
           #*:        *           -=.             +-                                  .=            
        =:%+         -:             -=.            +-                                   --          
        -%:          *                -=.           *:                                    +.        
       :%-..        =.                  -=.          #                                     -:       
      :=#   ..      +                     -=.        ==                                     -=      
     ---+     .    =                        -=.      .#                                      .+     
    -: ==       .  =         :------::------:.-=.     %                                       .=    
   :-  ==        .=.     ---:.               :--#+.  .%                                        :-   
   =   .*        .+.. :=-                        :++ -+                                         =:  
  +     #.       +  -=:                            :*%-*:                                        *  
 :=     :#      :=:=   .                    :-----: =+-+                                         .+ 
 *       -*     *=-     . .-        :::::::.       :*  .#+.                                       + 
:-        -+   :#.        --::-----:              :*     ++=                                      .-
+          :*. *.    .:::::*%:                   ++       +.-=.                                    +
+           -#**----:       .=                 -*.         +  -=                                   =
*           +.#=+:           +  .           .=+:           =.   -=.                                =
=            -+  :++:         +   ..     .=+=              .=     -=.                              -
=            %-     :====-:.  =.  .:--===-                  *       -=.                            -
+           +--          .:--==#==-:.=                      +         -=.                          =
*           + *                =.    :                     .=           -=.                        =
+          =  *                 +                          =              -=.                      +
:-         =  .=                =:                         =                -=.                   .-
 *        +    =:                *                        *                   -=.                 + 
 :-      .+     =-               :-                     .+                      -=.              .+ 
  *      *       :=               *                    :=                         -=             *  
   =    :-         =:             .-                 .=:                            -=.         =:  
   -:   *           .=-            +               .=-                                -=       :-   
    =: -:              --:         :-           :--:                                    -=.   .=    
     =:+                  ----.     *       :---.                                         -= .+     
    --=*----------------------=*+=--=+--=+*+------------------------------------------------%+:.    
    :: :=                           +:-                                                    -- :.    
        .=.                                                                               =.        
          -=                                                                            -=          
           .=:                                                                        .=.           
             .=:                                                                    .+:             
               :--                                                                :-:               
                  --                                                            -=.                 
                    :--.                                                     --:                    
                       :--:                                              .--:                       
                          .-:-:                                      ::--.                          
                               :----.                          .:----                               
                                    .:::::::::-::::::--::::::::.                             
 */
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define debug(x) cerr << #x << " is " << x << "\n"
#define hehe ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repb(i, a, b) for (int i = b; i >= a; i--)
#define pii pair<int, int>
#define linebreak cout << "---------------------------------------------------------\n"
#define f first
#define s second
#define pb push_back
// good luck
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
const int MS = 2e5+5, mod = 1e9+7;
int n, k, a[MS];
int32_t main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++) cin >> a[i];
	int ans = a[n]-a[1]+1;
	vector<int> diff;
	for (int i = 1; i < n; i++) diff.pb(a[i+1]-a[i]-1);
	sort(diff.begin(), diff.end());
	reverse(diff.begin(), diff.end());
	for (int i = 0; i < k-1; i++) ans -= diff[i];
	cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 436 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 436 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 1 ms 456 KB Output is correct
14 Correct 2 ms 600 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 436 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 1 ms 456 KB Output is correct
14 Correct 2 ms 600 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 30 ms 3280 KB Output is correct
17 Correct 30 ms 3284 KB Output is correct
18 Correct 30 ms 3320 KB Output is correct
19 Correct 30 ms 3272 KB Output is correct
20 Correct 30 ms 3332 KB Output is correct
21 Correct 30 ms 3284 KB Output is correct
22 Correct 35 ms 3276 KB Output is correct
23 Correct 31 ms 3324 KB Output is correct
24 Correct 31 ms 3284 KB Output is correct