Submission #918267

# Submission time Handle Problem Language Result Execution time Memory
918267 2024-01-29T14:01:32 Z vjudge1 Stove (JOI18_stove) C++17
0 / 100
2 ms 600 KB
//******************/
//*   I<3   C++    */
//*  I WANT ANY AC */
//* I LOVE PROGRAM!*/
//*IT'S long longERESTING*/
//* I LOVE PROGRAM!*/
//*  IN CONTESTS   */
//*   GET SCORE    */
//*    AC CODE     */
//*     LET'S      */
//*      GO        */
//*  Written by:   */
//*   Duc Minh     */






#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <algorithm>
#include <string>
#include <queue>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <deque>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define  file(name)  freopen(name".inp", "r", stdin);\
                     freopen(name".out", "w", stdout);
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define TIME        (1.0 * clock() / CLOCKS_PER_SEC)
#define all(a)      a.begin(),a.end()
#define endl        "\n"
#define all1(a)     a+1,a+n+1
#define unordered_map  map
#define Accepted 0      
// #define push_back   emplace_back
// #define gcd(a,b)    __gcd(a,b);
// #define lcm(a,b)    (a*b)/gcd(a,b);

const long long INF = (long long)1e9;
const long long MOD = (long long)1e9+7;
const long long MODD = 14062008; /// 998244353
const long long maxN = 2e5+9;
const long long LOG = 30;







///--------------------------------


void solve();

signed main(){

    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        file("ducminh");
    #endif

    // file("tbrackets");







    long long t;


    // cin >> t;

    t=1;



    while (t--){




        solve();


    }





    cerr << "Time elapsed: " << TIME << "s.\n";
    cerr << "ducminh" << "\n";
    return Accepted;
}



///--------------------[PROBLEM SOLUTION]--------------------///




void solve(){



    int n,k,ans=INF,a[200009],truoc=0;
    vector<pair<int,int>> luu;
    priority_queue<int> luu1;

    cin >> n >> k;

    int x;
    cin >> x;
    ans=x;
    truoc=x;

    for (int i=1; i<=n-1; i++){
        cin >> x;

        luu.push_back({x,x+1});

        luu1.push(x-truoc-1);
        truoc=x;
    }
    if(n==1) return cout << 1, void();


    ans=x-ans+1;

    k--;
    while (k--){
        ans-=luu1.top();
        luu1.pop();
    }


    cout << ans;



}





Compilation message

stove.cpp: In function 'void solve()':
stove.cpp:124:21: warning: unused variable 'a' [-Wunused-variable]
  124 |     int n,k,ans=INF,a[200009],truoc=0;
      |                     ^
stove.cpp: In function 'int main()':
stove.cpp:40:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 | #define  file(name)  freopen(name".inp", "r", stdin);\
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:74:9: note: in expansion of macro 'file'
   74 |         file("ducminh");
      |         ^~~~
stove.cpp:41:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |                      freopen(name".out", "w", stdout);
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:74:9: note: in expansion of macro 'file'
   74 |         file("ducminh");
      |         ^~~~
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -