[Logo] Mendo Judge Discussion Board - Forums
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
Messages posted by: Kosta F
Forum Index » Profile for Kosta F » Messages posted by Kosta F
Author Message
фала
Точно решение ми јавува само за првите два тест случаи, а јас со што и да пробам ми дава точен резултат


#include <iostream>
using namespace std;

int main(){
int n,m,x,naj=0,rez=0;
cin>>n>>m;
int arr[1001]={0};
for(int i=0;i<n;i++){
cin>>x;
arr[x]=x;
if(x>naj)
naj=x;
}
int y=m;
for(int i=naj;i>0;i--){
if(arr[i]!=0 && y%m==0){
rez=rez+2*arr[i];
y++;
}
else if(arr[i]!=0)
y++;
}
cout<<rez;
}
 
Forum Index » Profile for Kosta F » Messages posted by Kosta F
Go to:   
Powered by JForum 2.1.8 © JForum Team