Codeforces 789 A Anastasia and pebbles 水题

  题目链接: http://codeforces.com/contest/789/problem/A

  题目描述: 水题

  解题思路: 挨个遍历除以容量就可以

  代码: 

#include <iostream>
#include <cstdio>
#include <map>
#include <iterator>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstring>
using namespace std;

typedef long long ll;

int main() {
    int n, k;
    scanf( "%d%d", &n, &k );
    ll ans = 0;
    for( int i = 1; i <= n; i++ ) {
        int num;
        scanf( "%d", &num );
        ans += ll(num/k+(num%k!=0));
    }
    printf( "%lld
", ans/2+(ans%2!=0) );
    return 0;
}
View Code

  思考: 这是我切的速度最快的一道水题了吧, 但是没想到第二道题让我痛不欲生的...........

原文地址:https://www.cnblogs.com/FriskyPuppy/p/7622950.html