Submission #855183

# Submission time Handle Problem Language Result Execution time Memory
855183 2023-09-30T13:20:18 Z ooscode Stove (JOI18_stove) C++17
50 / 100
1 ms 860 KB
// IN THE NAME OF ALLAH
// YA IMAM REZA

#include<bits/stdc++.h>
 
using namespace std;
 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define wall cerr << "------------------------------------" << endl
#define pb push_back
#define pob pop_back
#define F first
#define S second
#define all(x) x.begin() , x.end()
#define int ll
#define kids int tm = (tl + tr)>>1; int cl = v<<1; int cr = v<<1|1
#define test int n;cin >> n;while(n--)
#define file freopen("input.txt" , "r" , stdin); freopen("output.txt" , "w" , stdout)
#define debug while(1) cout << "TEST\n"

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#pragma GCC optimize("Ofast")
 
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll , ll> pll;
typedef pair<pii,int> piii;
typedef pair<pll , ll> plll;
 
const int N = 5e3+10;
const int K = 400+10;
const ll mod = 1e9+7;
const ll INF = 1e9+10;
const int P = 31;
const int lg = 25;

const int delta = 30103; 

int has;
int t[N];
int n , k;

void solve() {
    cin >> n >> k;
    for(int i = 1 ; i <= n ; i++)
        cin >> t[i];

    has = t[n] + 1 - t[1];

    set<pii> s;
    for(int i = 2 ; i <= n ; i++)
        s.insert({t[i-1] - t[i] + 1 , i});

    for(int i = 1 ; i <= k-1 ; i++) {
        auto x = *s.begin();
        // cout << x.S << "\n";
        s.erase(s.begin());
        has += x.F;
    }

    cout << has << "\n";
}

signed main()
{   
    fast;
    solve();
} 
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 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 600 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 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 600 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 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 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 600 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 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Runtime error 1 ms 860 KB Execution killed with signal 11
17 Halted 0 ms 0 KB -