Submission #45150485


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
int main(void){
  unsigned long long n, d, p, sum=0;
  cin>>n>>d>>p;
  vector<int> f(n);
  for(int i=0;i<n;i++){
    cin>>f[i];
    sum+=f[i];
  }
  sort(f.begin(),f.end(),greater());
  unsigned long long pay=0;
  for(int i=0;i<n;i+=d){
    for(int j=i;j<min(n,d+i);j++){
      pay+=f[j];
    }
    if(pay>p){
      sum-=(pay-p);
      pay=0;
    }else{break;}
  }
  cout<<sum<<endl;
  
  
  
}

Submission Info

Submission Time
Task C - Blue Spring
User justysfh
Language C++ 20 (gcc 12.2)
Score 300
Code Size 465 Byte
Status AC
Exec Time 61 ms
Memory 4084 KiB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:7:16: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long long unsigned int’ [-Wsign-compare]
    7 |   for(int i=0;i<n;i++){
      |               ~^~
Main.cpp:13:16: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long long unsigned int’ [-Wsign-compare]
   13 |   for(int i=0;i<n;i+=d){
      |               ~^~
Main.cpp:14:18: warning: comparison of integer expressions of different signedness: ‘int’ and ‘const long long unsigned int’ [-Wsign-compare]
   14 |     for(int j=i;j<min(n,d+i);j++){
      |                 ~^~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 36
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt
Case Name Status Exec Time Memory
example_00.txt AC 1 ms 3452 KiB
example_01.txt AC 1 ms 3464 KiB
example_02.txt AC 1 ms 3452 KiB
hand_00.txt AC 53 ms 3840 KiB
hand_01.txt AC 54 ms 3988 KiB
hand_02.txt AC 19 ms 3912 KiB
hand_03.txt AC 1 ms 3504 KiB
hand_04.txt AC 1 ms 3504 KiB
hand_05.txt AC 1 ms 3452 KiB
hand_06.txt AC 1 ms 3456 KiB
hand_07.txt AC 1 ms 3448 KiB
random_00.txt AC 61 ms 3960 KiB
random_01.txt AC 60 ms 3912 KiB
random_02.txt AC 58 ms 3908 KiB
random_03.txt AC 54 ms 3936 KiB
random_04.txt AC 49 ms 3864 KiB
random_05.txt AC 43 ms 3904 KiB
random_06.txt AC 43 ms 3844 KiB
random_07.txt AC 60 ms 3984 KiB
random_08.txt AC 59 ms 3840 KiB
random_09.txt AC 56 ms 3868 KiB
random_10.txt AC 56 ms 3864 KiB
random_11.txt AC 52 ms 3908 KiB
random_12.txt AC 43 ms 3964 KiB
random_13.txt AC 39 ms 3948 KiB
random_14.txt AC 61 ms 3912 KiB
random_15.txt AC 60 ms 3848 KiB
random_16.txt AC 58 ms 3916 KiB
random_17.txt AC 52 ms 3992 KiB
random_18.txt AC 50 ms 3960 KiB
random_19.txt AC 43 ms 3988 KiB
random_20.txt AC 39 ms 4084 KiB
random_21.txt AC 61 ms 3888 KiB
random_22.txt AC 59 ms 3860 KiB
random_23.txt AC 57 ms 3856 KiB
random_24.txt AC 55 ms 3840 KiB