답안 #48576

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
48576 2018-05-16T17:52:09 Z MladenP Sterilizing Spray (JOI15_sterilizing) C++17
80 / 100
5000 ms 8472 KB
#include<bits/stdc++.h>
#define STIZE(x) fprintf(stderr, "STIZE%d\n", x);
#define PRINT(x) fprintf(stderr, "%s = %d\n", #x, x);
#define NL(x) printf("%c", " \n"[(x)]);
#define lld long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mid (l+r)/2
#define endl '\n'
#define all(a) begin(a),end(a)
#define sz(a) int((a).size())
#define LINF 1000000000000000LL
#define INF 1000000000
#define EPS 1e-9
using namespace std;
#define MAXN 100010
set<int> s;
vector<int> izbaciti;
lld bit[MAXN], a[MAXN];
lld query(int idx) {
    lld rez = 0;
    for( ; idx > 0; idx -= idx&-idx) rez += bit[idx];
    return rez;
}
void update(int idx, lld val) {
    val -= a[idx]; a[idx] += val;
    for( ; idx < MAXN; idx += idx&-idx) bit[idx] += val;
}
int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    lld N, Q, K, a1; cin >> N >> Q >> K;
    for(int i = 1; i <= N; i++) {
        cin >> a1; update(i, a1);
        if(a[i] != 0) s.insert(i);
    }
    while(Q--) {
        int type, u1, u2; cin >> type >> u1 >> u2;
        if(type == 1) {
            update(u1, u2);
            if(u2 != 0) s.insert(u1);
        } else if(type == 2) {
            for(auto it = s.lower_bound(u1); it != s.end(); it++) {
                if(*it > u2) break;
                update(*it, a[*it]/K);
                if(a[*it] == 0) izbaciti.pb(*it);
            }
            for(auto x : izbaciti) s.erase(x);
            izbaciti.clear();
        } else {
            cout << query(u2) - query(u1-1) << endl;
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 5 ms 628 KB Output is correct
3 Correct 3 ms 628 KB Output is correct
4 Correct 7 ms 628 KB Output is correct
5 Correct 7 ms 764 KB Output is correct
6 Correct 6 ms 840 KB Output is correct
7 Correct 6 ms 840 KB Output is correct
8 Correct 7 ms 840 KB Output is correct
9 Correct 8 ms 928 KB Output is correct
10 Correct 6 ms 928 KB Output is correct
11 Correct 7 ms 928 KB Output is correct
12 Correct 7 ms 928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5035 ms 4832 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 4832 KB Output is correct
2 Correct 19 ms 4832 KB Output is correct
3 Correct 24 ms 4832 KB Output is correct
4 Correct 46 ms 4832 KB Output is correct
5 Correct 70 ms 5516 KB Output is correct
6 Correct 70 ms 5516 KB Output is correct
7 Execution timed out 5012 ms 5516 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 99 ms 5516 KB Output is correct
2 Correct 101 ms 5516 KB Output is correct
3 Correct 125 ms 5516 KB Output is correct
4 Correct 105 ms 5516 KB Output is correct
5 Correct 165 ms 7952 KB Output is correct
6 Correct 179 ms 8052 KB Output is correct
7 Correct 161 ms 8052 KB Output is correct
8 Correct 218 ms 8052 KB Output is correct
9 Correct 182 ms 8328 KB Output is correct
10 Correct 219 ms 8340 KB Output is correct
11 Correct 200 ms 8472 KB Output is correct
12 Correct 276 ms 8472 KB Output is correct