답안 #333510

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
333510 2020-12-06T17:32:32 Z Vladth11 Meteors (POI11_met) C++14
61 / 100
1118 ms 65536 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define debug(x) cerr << #x << " " << x << "\n"
#define debug_with_space(x) cerr << #x << " " << x << " "

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair <ll, ll> pii;
typedef pair <ll, pii> piii;
typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> OST;

const ll NMAX = 300001;
const ll INF = (1 << 16) - 1;
const ll MOD = 1000000007;
const ll BLOCK = 101;
const ll nr_of_bits = 20;

struct ura{
    int a, b, c;
};

vector <ura> segm;
vector <int> reg[NMAX];
vector <int> check[NMAX];
int n, m, k;
int req[NMAX], l[NMAX], r[NMAX];

class AIB{
    int aib[NMAX * 4];
    void update(int x, int val){
        for(int i = x; i <= m; i+=i&(-i)){
            aib[i] += val;
        }
    }
    int query(int x){
        int sum = 0;
        for(int i = x; i > 0; i-=i&(-i)){
            sum += aib[i];
        }
        return sum;
    }
public:
    void ru(int l, int r, int val){
        if(l <= r){
            update(l, val);
            update(r + 1, -val);
        }
        if(l > r){
            update(l, val);
            update(1, val);
            update(r + 1, -val);
        }
    }
    int cn(int x){
        return query(x);
    }
    void init(){
        for(int i = 1; i <= m; i++){
            aib[i] = 0;
        }
    }
}aib;

void baga(){
    aib.init();
    int i;
    for(i = 1; i <= k; i++)
        check[i].clear();
    for(i = 1; i <= n; i++){
        int mid = (l[i] + r[i]) / 2;
        check[mid].push_back(i);
    }
    for(i = 0; i < k; i++){
        aib.ru(segm[i].a, segm[i].b, segm[i].c);
        for(auto x : check[i + 1]){
            int s = 0;
            for(auto y : reg[x]){
                s += aib.cn(y);
            }
            int mid = i + 1;
            if(s >= req[x]){
                r[x] = mid;
            }else{
                l[x] = mid + 1;
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int i, x;
    cin >> n >> m;
    for(i = 1; i <= m; i++){
        cin >> x;
        reg[x].push_back(i);
    }
    for(i = 1; i <= n; i++){
        cin >> req[i];
    }
    cin >> k;
    for(i = 1; i <= k; i++){
        ura x;
        cin >> x.a >> x.b >> x.c;
        segm.push_back(x);
    }
    for(i = 1; i <= n; i++){
        l[i] = 1;
        r[i] = k + 1;
    }
    for(int i = 1; i <= nr_of_bits; i++){
        baga();
    }
    for(i = 1; i <= n; i++){
        if(l[i] != k + 1)
        cout << l[i] << "\n";
        else cout << "NIE\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 14572 KB Output is correct
2 Correct 11 ms 14572 KB Output is correct
3 Correct 11 ms 14572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 14592 KB Output is correct
2 Correct 11 ms 14572 KB Output is correct
3 Correct 11 ms 14572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 88 ms 17252 KB Output is correct
2 Correct 132 ms 20068 KB Output is correct
3 Correct 132 ms 18808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 126 ms 18276 KB Output is correct
2 Correct 133 ms 18296 KB Output is correct
3 Correct 146 ms 19488 KB Output is correct
4 Correct 46 ms 17264 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 100 ms 17508 KB Output is correct
2 Correct 114 ms 20584 KB Output is correct
3 Correct 64 ms 15976 KB Output is correct
4 Correct 127 ms 19300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 111 ms 16788 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1118 ms 65536 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1113 ms 65536 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -