풀이 : 뒤에서 부터 돌면서 풀기 -> 가장 큰 이익을 얻기 위해선 가장 높은 매매가일 때 판매해야 하기 때문 Code public class Solution1859 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int T = sc.nextInt(); for (int tc = 1; tc = 0; j--) { if(arr[j] > max_value) { max_value = arr[j]; // 현재 값이 max보다 크면 max 갱신 } diff += max_value - arr[j]; // 작으면 그 차이가 이익이므로 더함 } System.out.printf("#%d %d\n", tc, diff); } sc.clo..