smkwon97   2년 전

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.<i>in</i>));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.<i>out</i>));

        StringTokenizer nmk = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(nmk.nextToken());
        int m = Integer.parseInt(nmk.nextToken());
        int k = Integer.parseInt(nmk.nextToken());

        int arr[] = new int[n];

        for (int i=0; i<n; i++) {
            arr[i] = Integer.parseInt(br.readLine());
        }

        for (int i=n+2; i<=(n+m+k+1); i++) {
            StringTokenizer abc = new StringTokenizer(br.readLine());
            int a = Integer.parseInt(abc.nextToken());
            int b = Integer.parseInt(abc.nextToken());
            int c = Integer.parseInt(abc.nextToken());
            int sum = 0;
            if (a == 1) {
                arr[b-1] = c;
            } else if (a == 2) {
                for (int j=b-1; j<c; j++) {
                    sum += arr[j];
                }
                bw.write(String.valueOf(sum));
                bw.write("\n");
            }
        }
        bw.flush();
        bw.close();
    }
}

siyamaki   2년 전

입력으로 주어지는 모든 수는 -263보다 크거나 같고, 263-1보다 작거나 같은 정수이다.

참고로 gpt로 답을 찾는 방식보단 문제의 입력 값을 찾거나 직접 구글에서 Exception 내용을 찾아보는게 훨씬 빠릅니다

smkwon97   2년 전

넵 참고하여서 해결하겠습니다! 답변 감사합니다!!

댓글을 작성하려면 로그인해야 합니다.