59722023-10-07 08:21:05mmatedBájital (80 pont)cpp17Accepted 80/8014ms4964 KiB
#include <bits/stdc++.h>
using namespace std;
#define f(i,k,n) for(int i=k; i<n; i++)
#define ll long long
const int inf = INT_MAX;

void solve()
{
    int n,x;
    cin>>n>>x;
    ll a=0,b=0;
    int q;
    f(i,0,n)
    {
        cin>>q;
        a+=q/x;
        b+=q%x;
    }
    if(a>b && (a-b)%(x+1)==0) cout<<a-(a-b)/(x+1);
    else if(a>b)    cout<<a-(a-b)/(x+1)-1;
    else   cout<<a<<"\n";
   /*while(b<a)
    {
        a--;
        b+=x;
    }
    cout<<a<<"\n";
    */
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    //cin>>t;
    while(t--)  solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base80/80
1Accepted0/03ms1892 KiB
2Accepted0/03ms2116 KiB
3Accepted2/22ms2208 KiB
4Accepted2/23ms2348 KiB
5Accepted2/23ms2536 KiB
6Accepted2/23ms2736 KiB
7Accepted4/43ms2824 KiB
8Accepted4/43ms2952 KiB
9Accepted2/214ms3172 KiB
10Accepted2/214ms3388 KiB
11Accepted2/214ms3472 KiB
12Accepted2/214ms3468 KiB
13Accepted2/214ms3604 KiB
14Accepted2/214ms3796 KiB
15Accepted2/214ms4004 KiB
16Accepted2/214ms4220 KiB
17Accepted2/214ms4300 KiB
18Accepted2/214ms4436 KiB
19Accepted2/214ms4528 KiB
20Accepted2/214ms4608 KiB
21Accepted2/214ms4604 KiB
22Accepted2/214ms4696 KiB
23Accepted4/43ms4600 KiB
24Accepted4/42ms4508 KiB
25Accepted4/42ms4516 KiB
26Accepted4/410ms4524 KiB
27Accepted4/414ms4532 KiB
28Accepted4/414ms4528 KiB
29Accepted4/414ms4528 KiB
30Accepted2/214ms4528 KiB
31Accepted2/214ms4752 KiB
32Accepted2/214ms4964 KiB
33Accepted2/214ms4948 KiB