# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
496332 | Nalrimet | 새로운 문제 (POI11_met) | C++17 | 6096 ms | 16248 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int N = 3 * 1e5 + 5;
const long long inf = 1000000000;
#define ll long long
#define F first
#define S second
#define pb push_back
int n, m, a[N], k, l, r, ans[N], j;
ll b[N], x;
set<int> st;
vector<int> del;
main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for(int i = 1; i <= m; ++i){
cin >> a[i];
st.insert(i);
}
for(int i = 1; i <= n; ++i){
cin >> b[i];
}
cin >> k;
for(int i = 1; i <= k; ++i){
cin >> l >> r >> x;
if(l <= r){
auto to = st.lower_bound(l);
if(to == st.end()) continue;
for(to; *to <= r;){
j = *to;
if(b[a[j]] <= 0) del.pb(j);
else{
b[a[j]] -= x;
if(b[a[j]] <= 0) {ans[a[j]] = i; del.pb(j);}
}
to++;
if(to == st.end()) break;
}
}
else{
auto to = st.lower_bound(l);
if(to == st.end()) continue;
for(to; *to <= m; ){
j = *to;
if(b[a[j]] <= 0) del.pb(j);
else{
b[a[j]] -= x;
if(b[a[j]] <= 0) {ans[a[j]] = i; del.pb(j);}
}
to++;
if(to == st.end()) break;
}
to = st.begin();
if(to == st.end()) continue;
for(to; *to <= r; ){
j = *to;
if(b[a[j]] <= 0) del.pb(j);
else{
b[a[j]] -= x;
if(b[a[j]] <= 0) {ans[a[j]] = i; del.pb(j);}
}
to++;
if(to == st.end()) break;
}
}
for(auto to : del){
st.erase(to);
}
del.clear();
}
for(int i = 1; i <= n; ++i){
if(ans[i]) cout << ans[i] << '\n';
else cout << "NIE\n";
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |