공부기록/백준

[백준] 11508번 2+1 세일

메델 2023. 11. 21. 05:44
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner kb = new Scanner(System.in);
    	int n = kb.nextInt();
    	List<Integer> list = new ArrayList<>();
    	
    	for(int i=0; i<n; i++) {
    		list.add(kb.nextInt());
    	}
    	
    	Collections.sort(list, Collections.reverseOrder());
    	
    	int sum = 0;
    	
    	for(int i=0; i<n; i++) {
    		if((i+1)%3 == 0) {
    			continue;
    		}else {
    			sum += list.get(i);
    		}
    	}
    	
    	System.out.print(sum);

    	
    }
}