Submission #1042710

# Submission time Handle Problem Language Result Execution time Memory
1042710 2024-08-03T09:56:26 Z vjudge1 Meteors (POI11_met) C++17
24 / 100
6000 ms 9556 KB
#include <bits/stdc++.h>
using namespace std;

#define SPEED ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define str string
#define pb push_back
#define pf push_front
#define nl "\n"
#define ll long long
#define int long long
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define ff first
#define ss second
#define len(a) a.size()
#define pii pair<int,int>
const int N = 5e5 + 101;
const int md = 998244353;
const int mod = 1e9 + 7;
const int mega = 1e6 + 3;
const int inf = 1e18;

ll gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

ll lcm(int a, int b) {
    return (a / gcd(a, b)) * b;
}
int binpow(int a, int b, int m = mod) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

void solve(){
    int n , m;
    cin >> n >> m;
    int a[m + 1];
    for(int i = 1; i <= m; ++i)cin >> a[i];
    int p[n + 1];
    for(int i = 1; i <= n; ++i)cin >> p[i];
    int k;
    cin >> k;
    map<int , int>mp;
    map<int , int>ans;
    for(int j = 1; j <= k; ++j){
        int l , r;
        cin >> l >> r;
        int x;
        cin >> x;
        if(l <= r){
            for(int i = l; i <= r; i++){
                mp[a[i]] += x;
                if(mp[a[i]] >= p[a[i]] && ans[a[i]] == 0)ans[a[i]] = j;
            }
        }
        else{
            for(int i = l; i <= m; ++i){
                mp[a[i]] += x;
                if(mp[a[i]] >= p[a[i]] && ans[a[i]] == 0)ans[a[i]] = j;
            }
            // for(int i = 1; i <= n; ++i){
            //     if(mp[i] >= p[i])ans[i] = j;
            // }
            for(int i = 1; i <= r; ++i){
                mp[a[i]] += x;
                if(mp[a[i]] >= p[a[i]] && ans[a[i]] == 0)ans[a[i]] = j;
            }
            // for(int i = 1; i <= n; ++i){
            //     if(mp[i] >= p[i])ans[i] = j;
            // }
        }
    }
    for(int i = 1; i <= n; ++i){
        if(mp[i] < p[i])cout << "NIE";
        else {
            // cout << mp[i] << nl;
            cout << ans[i];
        }
        cout << nl;
    }
}

signed main() {
    // SPEED;
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    #ifndef ONLINE_JUDGE
    cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 348 KB Output is correct
2 Correct 12 ms 348 KB Output is correct
3 Correct 15 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 348 KB Output is correct
2 Correct 19 ms 476 KB Output is correct
3 Correct 22 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 6062 ms 860 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 6034 ms 1564 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 6044 ms 1108 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 6036 ms 600 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 6020 ms 9556 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 6033 ms 8648 KB Time limit exceeded
2 Halted 0 ms 0 KB -