답안 #496461

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
496461 2021-12-21T08:40:30 Z Ziel Meteors (POI11_met) C++17
24 / 100
6000 ms 4164 KB
/**
 * LES GREATEABLES BRO TEAM
**/

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
#define sz(x) (int)x.size()
const bool FLAG = false;
void setIO(const string &f = "");

#define int ll

void solve() {
    int n, m;
    cin >> n >> m;

    vector<int> o(m + 1);
    for (int i = 1; i <= m; i++)
    	cin >> o[i];

    vector<int> p(n + 1);
    for (int i = 1; i <= n; i++)
    	cin >> p[i];

    int q;
    cin >> q;
    vector<int> ans(n + 1, 1000000000);
    for (int rep = 1; rep <= q; rep++) {
    	int l, r, x;
    	cin >> l >> r >> x;
    	if (l > r) {
    		for (int i = l; i <= m; i++) {
    			p[o[i]] -= x;
    		}
    		for (int i = 1; i <= r; i++) {
    			p[o[i]] -= x;
    		}
    	} else {
    		for (int i = l; i <= r; i++) {
    			p[o[i]] -= x;
    		}
    	}
    	for (int i = 1; i <= n; i++) {
    		if (p[i] <= 0)
    			ans[i] = min(ans[i], rep);
    	}
    }
    for (int i = 1; i <= n; i++) {
    	if (ans[i] == 1000000000)
    		cout << "NIE\n";
    	else
    		cout << ans[i] << '\n';
    }
}

signed main() {
    setIO();
    
    int tt = 1;
    if (FLAG) {
    	cin >> tt;
    }
    while (tt--) {
    	solve();
    }
    
    return 0;
}

void setIO(const string &f) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    if (sz(f) && fopen((f + ".in").c_str(), "r")) {
        freopen((f + ".in").c_str(), "r", stdin);
        freopen((f + ".out").c_str(), "w", stdout);
    }
}

Compilation message

met.cpp: In function 'void setIO(const string&)':
met.cpp:77:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   77 |         freopen((f + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
met.cpp:78:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   78 |         freopen((f + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 2 ms 204 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 2 ms 204 KB Output is correct
3 Correct 3 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1926 ms 776 KB Output is correct
2 Execution timed out 6062 ms 1100 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2864 ms 844 KB Output is correct
2 Correct 2788 ms 844 KB Output is correct
3 Execution timed out 6063 ms 972 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3588 ms 772 KB Output is correct
2 Execution timed out 6042 ms 1100 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4982 ms 716 KB Output is correct
2 Execution timed out 6096 ms 844 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 6088 ms 4164 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 6095 ms 3916 KB Time limit exceeded
2 Halted 0 ms 0 KB -