Submission #496228

# Submission time Handle Problem Language Result Execution time Memory
496228 2021-12-21T03:27:36 Z kingline Meteors (POI11_met) C++17
74 / 100
6000 ms 1800 KB
/*#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")*/
#include <bits/stdc++.h>
#define file(data) freopen(data".in", "r", stdin); freopen(data".out", "w", stdout);
#define pb push_back
#define all(data) data.begin(), data.end()
#define endl '\n'
#define ll long long
//#define int long long
#define pii pair < int, int >

using namespace std;

const int N = 3e5 + 5;
const int INF = 1e9;

int n, m, o[N], p[N], ans[N], num;

void change(int l, int r, int x) {
    for(int i = l; i <= r; i++) {
        if(p[o[i]] > 0) {
            p[o[i]] -= x;
            if(p[o[i]] <= 0) {
                ans[o[i]] = num;
            }
        }
    }
}

main() {
    //file("pieaters");
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= m; i++) {
        cin >> o[i];
    }
    for(int i = 1; i <= n; i++) {
        cin >> p[i];
    }
    int q;
    cin >> q;
    while(q--) {
        int l, r, x;
        num++;
        cin >> l >> r >> x;
        if(l <= r) {
            change(l, r, x);
        } else {
            change(l, m, x);
            change(1, r, x);
        }
    }
    for(int i = 1; i <= n; i++) {
        if(ans[i] == 0) cout << "NIE\n";
        else cout << ans[i] << endl;
    }
}






Compilation message

met.cpp:33:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   33 | main() {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 204 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 463 ms 528 KB Output is correct
2 Correct 5593 ms 672 KB Output is correct
3 Correct 2739 ms 612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1566 ms 588 KB Output is correct
2 Correct 2168 ms 588 KB Output is correct
3 Correct 1530 ms 716 KB Output is correct
4 Correct 10 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2020 ms 672 KB Output is correct
2 Correct 4301 ms 704 KB Output is correct
3 Correct 27 ms 204 KB Output is correct
4 Correct 2061 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2147 ms 504 KB Output is correct
2 Correct 3954 ms 596 KB Output is correct
3 Correct 1360 ms 524 KB Output is correct
4 Correct 4872 ms 832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 6053 ms 1800 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 6056 ms 1684 KB Time limit exceeded
2 Halted 0 ms 0 KB -