Created
March 3, 2016 07:54
-
-
Save jianminchen/635eae11620179c17945 to your computer and use it in GitHub Desktop.
HackerRank HourRank 6 - Lisa's workbook - Study Code (#12)
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 <cmath> | |
#include <algorithm> | |
#include <vector> | |
#include <cstring> | |
#include <deque> | |
#include <stack> | |
#include <stdio.h> | |
#include <map> | |
#include <set> | |
#include <time.h> | |
#include <string> | |
#include <fstream> | |
#include <queue> | |
#include <bitset> | |
#include <cstdlib> | |
#define X first | |
#define Y second | |
#define mp make_pair | |
#define pb push_back | |
#define pdd pair<double,double> | |
#define pii pair<ll,ll> | |
#define PI 3.14159265358979323846 | |
#define MOD 1000000007 | |
#define MOD2 (33LL+(ll)1e+17) | |
#define INF (1LL+(ll)1e+9) | |
#define x1 fldgjdflgjhrthrl | |
#define x2 fldgjdflgrtyrtyjl | |
#define y1 fldggfhfghjdflgjl | |
#define y2 ffgfldgjdflgjl | |
#define SQ 500400 | |
#define CI 43534 | |
#define N 228228 | |
#define eps 1e-9 | |
typedef long long ll; | |
typedef long double ld; | |
using namespace std; | |
ll i,j,n,k,k1,k2,k3,m,h,z,l,x,y,r,p,d; | |
ll a[100500], b[100500]; | |
int main() | |
{ | |
//freopen("input.txt","r",stdin); | |
cin >> n >> k; | |
for (i = 0; i < n; i++) | |
cin >> a[i]; | |
ll ans = 0; | |
for (i = 0; i < n; i++) | |
{ | |
for (j = 1; j <= a[i]; j+=k) | |
{ | |
m++; | |
if (m >= j && m <= min(j+k-1,a[i])) | |
ans++; | |
} | |
} | |
cout << ans << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment