Submission #477891

#TimeUsernameProblemLanguageResultExecution timeMemory
477891chungdinhRasvjeta (COCI17_rasvjeta)C++14
50 / 50
1 ms296 KiB
#include <iostream> #include <vector> #include <bitset> #include <queue> #include <algorithm> #include <cstring> #include <cmath> #include <stack> #include <set> #include <map> #include <cassert> #include <bits/stdc++.h> using namespace std; #define pb push_back #define ll long long #define ii pair<int,int> #define pll pair<long long, long long> #define fi first #define se second #define r first #define c second #define all(x) x.begin(), x.end() ostream& operator << (ostream& os, pair<int, int> a) { return os << a.first << " : " << a.second; } #define endl '\n' #define db(val) "["#val" = "<<(val)<<"] " #define cntbit(x) __builtin_popcount(x) const int N = 1000 + 5; const int iINF = 1e9; const ll MOD = 1e9 + 7; const ll MOD2 = 998244353; const ll INF = 1e18; int n, m, k; int a[N]; int main() { #ifdef CHUNGDINH freopen("main.inp","r",stdin); //freopen("main.out","w",stdout); #endif int res = 0; cin >> n >> m >> k; for (int i = 1; i <= m; i++) cin >> a[i]; sort(a + 1, a + 1 + m); int last = 0; for (int i = 1; i <= m; i++) { if (a[i] - k > last + 1) res += ceil(double(a[i] - k - 1 - (last + 1) + 1) / double(2 * k + 1)); last = a[i] + k; } if (last < n) res += ceil(double(n - (last + 1) + 1) / double(2 * k + 1)); cout << res; } /* Array bounds * long long vs int Garbage value Sometimes, VNOI views "arrays out of bounds" as "wrong answer" */
#Verdict Execution timeMemoryGrader output
Fetching results...