답안 #25129

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
25129 2017-06-20T07:32:40 Z 시제연(#1054) Sterilizing Spray (JOI15_sterilizing) C++
10 / 100
109 ms 4912 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, q, k;
ll arr[100100];

ll tree[270000];
int key = 131072;
void upd(int idx, ll val) {
    idx+=key;
    tree[idx] = val;
    idx>>=1;
    while(idx>0) {
        tree[idx] = tree[idx*2]+tree[idx*2+1];
        idx>>=1;
    }
}
ll getv(int s, int e) {
    ll res = 0;
    s+=key; e+=key;
    while(s<=e) {
        if (s&1) res += tree[s++];
        if (~e&1) res += tree[e--];
        s>>=1;e>>=1;
    }
    return res;
}
void solve1() {
    int i;
    for (i=0;i<n;i++) upd(i,arr[i]);
    for (i=0;i<q;i++) {
        int a, b, c;
        scanf("%d%d%d",&a,&b,&c);
        if (a==1) upd(b-1,c);
        else if (a==3) printf("%lld\n",getv(b-1,c-1));
    }
}

void solve() {
}

int main() {
    int i;
    scanf("%d%d%d",&n,&q,&k);
    for (i=0;i<n;i++) scanf("%lld",&arr[i]);
    if (k==1) solve1();
    else solve();

    return 0;
}

Compilation message

sterilizing.cpp: In function 'void solve1()':
sterilizing.cpp:36:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d",&a,&b,&c);
                                 ^
sterilizing.cpp: In function 'int main()':
sterilizing.cpp:47:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d",&n,&q,&k);
                             ^
sterilizing.cpp:48:44: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (i=0;i<n;i++) scanf("%lld",&arr[i]);
                                            ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 4912 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 4912 KB Output is correct
2 Correct 46 ms 4912 KB Output is correct
3 Correct 63 ms 4912 KB Output is correct
4 Correct 69 ms 4912 KB Output is correct
5 Correct 83 ms 4912 KB Output is correct
6 Correct 109 ms 4912 KB Output is correct
7 Correct 99 ms 4912 KB Output is correct
8 Correct 79 ms 4912 KB Output is correct
9 Correct 89 ms 4912 KB Output is correct
10 Correct 79 ms 4912 KB Output is correct
11 Correct 59 ms 4912 KB Output is correct
12 Correct 83 ms 4912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 4912 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 4912 KB Output isn't correct
2 Halted 0 ms 0 KB -