Created
March 3, 2016 08:16
-
-
Save jianminchen/599248d93d71a0155a0b to your computer and use it in GitHub Desktop.
HackerRank algorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <algorithm> | |
#include <cmath> | |
#include <cstdio> | |
#include <set> | |
#include <map> | |
#include <vector> | |
#include <queue> | |
#include <string> | |
#include <iomanip> | |
#include <stdio.h> | |
using namespace std; | |
typedef long long ll; | |
typedef long double ld; | |
ll big = 1000000007ll; | |
ll n,m,k,q,d; | |
ll T; | |
std::vector<ll> A; | |
int main() | |
{ | |
ll c1,c2,c3,c4,c5,c6; | |
ll x,y,z; | |
ll a,b,c,e; | |
ll s; | |
//freopen("test_input.txt","r",stdin); | |
//freopen("output.txt","w",stdout); | |
std::cin >> n >> k; | |
ll pn = 1; | |
ll ans = 0; | |
for(c1=0;c1<n;c1++){ | |
std::cin >> a; | |
A.push_back(a); | |
ll t = 0; | |
while(t < a){ | |
if(pn > t && pn <= min(t+k,a)){ans++;} | |
pn++; | |
t += k; | |
} | |
} | |
std::cout << ans << "\n"; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment