답안 #907664

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
907664 2024-01-16T01:33:14 Z andro Sterilizing Spray (JOI15_sterilizing) C++14
0 / 100
5000 ms 9264 KB
#include <bits/stdc++.h>

#define int long long

using namespace std;

const int N = 1e5 + 5;

int n;

struct segtree{
    int t[4*N];
    int query(int v,int tl,int tr,int l,int r){
        if(tl>r||tr<l)return 0;
        if(tl>=l&&tr<=r)return t[v];
        int tm=(tl+tr)/2;
        return query(v*2,tl,tm,l,r)+query(v*2+1,tm+1,tr,l,r);
    }
    void update(int v,int tl,int tr,int index,int value){
        if(tl==tr)t[v]=value;
        else {
            int tm=(tl+tr)/2;
            if(index<=tm)update(v*2,tl,tm,index,value);
            else update(v*2+1,tm+1,tr,index,value);
            t[v]=t[v*2]+t[v*2+1];
        }
    }
    int query(int l, int r) {
        return query(1, 1, n, l, r);
    }
    void update(int i, int value) {
        update(1, 1, n, i, value);
    }
}seg;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int q, k;
    cin >> n >> q >> k;
    vector<int> a(n + 1);
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        seg.update(i, a[i]);
    }
    set<int> s;
    for(int i = 1; i <= n; i++) {
        s.insert(i);
    }
    vector<int> P(n + 1);
    const int limit = 100;
    while(q--) {
        int o;
        cin >> o;
        if(o == 1) {
            int l, r;
            cin >> l >> r;
            seg.update(l, r);
        }
        else if(o == 2) {
            int l, r;
            cin >> l >> r;
            for(int i = l; i <= r; i++) {
                a[i] /= k;
            }
        }
        else {
            int l, r;
            cin >> l >> r;
            cout << seg.query(l, r) << "\n";
        }
    }
}

Compilation message

sterilizing.cpp: In function 'int main()':
sterilizing.cpp:51:15: warning: unused variable 'limit' [-Wunused-variable]
   51 |     const int limit = 100;
      |               ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3406 ms 6316 KB Output is correct
2 Correct 2124 ms 5008 KB Output is correct
3 Correct 3412 ms 7980 KB Output is correct
4 Execution timed out 5021 ms 9264 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 109 ms 1016 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1321 ms 6384 KB Output isn't correct
2 Halted 0 ms 0 KB -