216492026-01-13 17:44:17algoproBájital (80 pont)cpp17Wrong answer 12/80300ms1272 KiB
// UUID: 6eec76bd-c392-4cdd-81f1-215195e82586
#include <bits/stdc++.h>
using namespace std;


int main() {
   long long N=0;
   cin >> N;
   long long X=0;
   cin >> X;


   long long FINAL=0;
   long long PotionBase=0;
   long long PotionExtra=0;


   vector<long long>A(N);
   for (long long i=0; i<N; i++) {
       cin >> A[i];
       //Reading in the input
       PotionBase+=A[i]%X;
       //Remaining part, which can not be grouped to size X packeges of the same ingredient
       PotionExtra+=A[i]/X; //it really should be ...+=(A[i]-(A[i]%X))/X;
       //These are size Xpackeges of the same ingredient (Possibly will be disassembled to PotionBases)
   }

   for (long long i=0; i!=1;) {
       if (PotionBase<PotionExtra) {
           FINAL+=PotionBase;
           PotionExtra-=PotionBase;
           PotionBase=0;

           //Disassemlbing size X PotionExtras to X number of PotionBases
           PotionBase+=X*(PotionExtra/X);
           PotionExtra-=(PotionExtra/X);
       } else {
           FINAL+=PotionExtra;
           PotionBase-=PotionExtra;
           PotionExtra=0;
           //Cycle suicide switch (it ends itself... so sad)
           i=1;
       }
   }


   cout << FINAL;
}


SubtaskSumTestVerdictTimeMemory
base12/80
1Accepted0/01ms316 KiB
2Wrong answer0/01ms316 KiB
3Wrong answer0/21ms508 KiB
4Wrong answer0/21ms316 KiB
5Wrong answer0/21ms316 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/42ms316 KiB
8Wrong answer0/42ms316 KiB
9Wrong answer0/237ms1192 KiB
10Wrong answer0/237ms1076 KiB
11Wrong answer0/237ms1260 KiB
12Wrong answer0/237ms1112 KiB
13Wrong answer0/237ms1076 KiB
14Wrong answer0/237ms1272 KiB
15Wrong answer0/237ms1204 KiB
16Wrong answer0/237ms1076 KiB
17Wrong answer0/237ms1076 KiB
18Wrong answer0/237ms1264 KiB
19Wrong answer0/239ms1076 KiB
20Wrong answer0/237ms1076 KiB
21Wrong answer0/239ms1196 KiB
22Wrong answer0/237ms1192 KiB
23Wrong answer0/41ms492 KiB
24Accepted4/42ms508 KiB
25Time limit exceeded0/4300ms316 KiB
26Accepted4/421ms1192 KiB
27Wrong answer0/437ms1076 KiB
28Wrong answer0/437ms1260 KiB
29Time limit exceeded0/4300ms1076 KiB
30Accepted2/237ms1076 KiB
31Accepted2/237ms1080 KiB
32Wrong answer0/237ms1076 KiB
33Wrong answer0/237ms1268 KiB