답안 #890458

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
890458 2023-12-21T09:43:16 Z vjudge1 Meteors (POI11_met) C++17
0 / 100
6000 ms 16980 KB
#include<bits/stdc++.h>

#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

void dgb_out() { cerr << "\n"; }
template<typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) { cerr << " " << H; dgb_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
 
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file(s) freopen(s".in", "r", stdin);freopen(s".out", "w", stdout);
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ft first
#define sd second
#define ll long long
#define pll pair<ll,ll>
const int N = 1e6 + 10;
const int M = 2e7 + 5;
const int B = 316;
const ll msize = 2;
const ll mod1 = 1e9 + 7;
const ll mod2 = 998244353;
const long double Phi = acos(-1);
const long long inf = 3e18;

ll binmul(ll x, ll ti, ll m);
ll binpow(ll x, ll ti, ll m);

struct Query {
    ll l, r, x;
} q[N];

ll n, m, k, a[N], b[N], sc[N];

bool check(int mid, int pos) {
    for (int i = 1; i <= m; ++ i) sc[i] = 0;
    for (int i = 1; i <= mid; ++ i) {
        if (q[i].l <= q[i].r) {
            sc[q[i].l] += q[i].x;
            sc[q[i].r + 1] -= q[i].x; 
        } else {
            sc[q[i].l] += q[i].x;
            sc[1] += q[i].x;
            sc[q[i].r + 1] -= q[i].x;
        }
    }

    ll sum = 0;
    for (int i = 1; i <= m; ++ i) {
        sc[i] += sc[i - 1];
        if (a[i] == pos) sum += sc[i];
    }
    return (sum >= b[pos]);
}

const void solve() {
    cin >> n >> m;
    for (int i = 1; i <= m; ++ i) cin >> a[i];
    for (int i = 1; i <= n; ++ i) cin >> b[i];

    cin >> k;
    for (int i = 1; i <= n; ++ i) cin >> q[i].l >> q[i].r >> q[i].x;

    for (int i = 1; i <= n; ++ i) {
        int l = 1, r = k, ans = -1;
        while (l <= r) {
            int mid = (l + r) / 2;
            if (check(mid, i)) r = mid - 1, ans = mid;
            else l = mid + 1;
        }
        if (ans == -1) cout << "NIE\n";
        else cout << ans << "\n";
    }
}  

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    srand(time(NULL));

    //file("monsters");

    int tt = 1;
    // cin >> tt;
    for (int i = 1; i <= tt; ++ i) {
        solve();
    }

    return 0;
} 


// Template functions
ll binmul(ll x, ll ti, ll m) { ll res = 0;while (ti){if(ti & 1)res += x;x += x;ti >>= 1; x %= m; res %= m;} return res;}
ll binpow(ll x, ll ti, ll m) { ll res = 1;while (ti){if(ti & 1)res=binmul(res,x,m);x=binmul(x,x,m);ti >>= 1; x %= m; res %= m;} return res;}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 6488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 6488 KB Output is correct
2 Correct 4 ms 6492 KB Output is correct
3 Incorrect 15 ms 6492 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 6041 ms 8828 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 6052 ms 8828 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 6041 ms 8832 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1154 ms 8828 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 6005 ms 16976 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 6065 ms 16980 KB Time limit exceeded
2 Halted 0 ms 0 KB -