# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
417610 | 2021-06-04T03:42:49 Z | Trickster | Stove (JOI18_stove) | C++14 | 1 ms | 460 KB |
//Suleyman Atayew #include <algorithm> #include <iostream> #include <string.h> #include <stdio.h> #include <vector> #include <bitset> #include <queue> #include <cmath> #include <map> #include <set> #define N 200010 #define ff first #define ss second #define pb push_back #define ll long long #define mod 1000000007 #define pii pair <int, int> #define sz(a) (int)(a.size()) ll bigmod(ll a, ll b) { if(b==0)return 1; ll ret = bigmod(a, b/2); return ret * ret % mod * (b%2 ? a : 1) % mod; } using namespace std; int n, k; int v[N]; vector <pii> V; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> k; for(int i = 1; i <= n; i++) cin >> v[i]; int ans = 0; for(int i = 1; i <= n; i++) { int x = i; while(v[i] == v[i+1]-1) i++; V.pb({v[x], v[i]}); ans += v[i]-v[x]+1; } vector <int> dis; for(int i = 1; i < V.size(); i++) dis.pb(V[i].ff-V[i-1].ss-1); sort(dis.begin(), dis.end()); for(int i = 0; i < V.size()-k; i++) ans += dis[i]; cout << ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Runtime error | 1 ms | 460 KB | Execution killed with signal 11 |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Runtime error | 1 ms | 460 KB | Execution killed with signal 11 |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Runtime error | 1 ms | 460 KB | Execution killed with signal 11 |
6 | Halted | 0 ms | 0 KB | - |