Submission #1089404

# Submission time Handle Problem Language Result Execution time Memory
1089404 2024-09-16T12:22:49 Z Mike_Vu Meteors (POI11_met) C++14
24 / 100
2 ms 604 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double dou;
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define BITj(x, j) (((x)>>(j))&1)
#define MASK(x) (1LL<<(x))

template<typename T> bool maximize(T &x, const T &y) {
    if (x < y) {x = y; return 1;}
    return 0;
}
template<typename T> bool minimize(T &x, const T &y) {
    if (x > y) {x = y; return 1;}
    return 0;
}

const int maxn = 1005;
int n, m, k;
int o[maxn], ans[maxn];
ll goal[maxn];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #define name "task"
    if (fopen(name".inp", "r")) {
        freopen(name".inp", "r", stdin);
        freopen(name".ans", "w", stdout);
    }
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        cin >> o[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> goal[i];
    }
    memset(ans, -1, sizeof(ans));
    cin >> k;
    for (int t = 1; t <= k; t++) {
        int l, r;
        ll val;
        cin >> l >> r >> val;
        if (l <= r) {
            for (int i = l; i <= r; i++) {
                goal[o[i]] -= val;
            }
        }
        else {
            for (int i = 1; i <= r; i++) {
                goal[o[i]] -= val;
            }
            for (int i = l; i <= m; i++) {
                goal[o[i]] -= val;
            }
        }
        //check
        for (int i = 1; i <= n; i++) {
            if (goal[i] <= 0 && ans[i] == -1) ans[i] = t;
        }
    }
    for (int i = 1; i <= n; i++) {
        if (ans[i] == -1) cout << "NIE";
        else cout << ans[i];
        cout << "\n";
    }
}

Compilation message

met.cpp: In function 'int main()':
met.cpp:32:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         freopen(name".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
met.cpp:33:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         freopen(name".ans", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -