Skip to content

Commit

Permalink
[01주차 조예빈] 백준12845번_모두의마블 (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jyebin authored and hepheir committed Oct 22, 2023
1 parent 90168c9 commit 21d8455
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions 01주차/조예빈/num12845.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import java.util.Scanner;

public class num12845 {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] cards = new int[n];

for(int i=0;i<n;i++){
cards[i] = sc.nextInt();
}
int maxCard = 0;
int maxCardIndex = 0;

for(int i=0;i<n;i++){
if(maxCard<cards[i]){
maxCard = cards[i];
maxCardIndex = i;
}
}
int total = 0;

for(int i=0;i<n;i++){
if(i!=maxCardIndex){
total += maxCard + cards[i];
}
}
System.out.println(total);
sc.close();
}
}

0 comments on commit 21d8455

Please sign in to comment.