답안 #496310

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
496310 2021-12-21T05:27:53 Z Ierus Meteors (POI11_met) C++17
49 / 100
6000 ms 5752 KB
#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
using namespace std;
#pragma GCC optimize ("unroll-loops,Ofast,O3")
#pragma GCC target("avx,avx2,fma")
#define F first
#define int long long
#define S second
#define sz(x) (int)x.size()
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define NFS ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
const int E = 1e9;
const long long inf = 1e18+777;
const int N = 3e5+777;
const int MOD = 1e9+7;
const bool I = 1;
int n, m, o[N], p[N];
vector<int> ans(N, -1);
signed main(){NFS;
	cin >> n >> m;
	for(int i = 1; i <= m; ++i){
		cin >> o[i];
	}
	for(int i = 1; i <= n; ++i){
		cin >> p[i];
	}
//	cerr << "P\n";for(int i = 1; i <= n; ++i){
//		cerr <<  p[i] << ' ';
//	}cerr << '\n';
	int que, cnt = 0; cin >> que;
	for(int l, r, a; que--;){
		++cnt;
		cin >> l >> r >> a;
//		cerr << "l: " << l << " r: " << r << " a: " << a<< '\n'; 
		if(l > r){
			for(int i = l; i <= m; ++i){
				p[o[i]] -= a;
				if(p[o[i]] <= 0 && ans[o[i]] == -1){
					ans[o[i]] = cnt;
				}
			}
			for(int i = 1; i <= r; ++i){
				p[o[i]] -= a;
				if(p[o[i]] <= 0 && ans[o[i]] == -1){
					ans[o[i]] = cnt;
				}
			}
		}else{
			for(int i = l; i <= r; ++i){
				p[o[i]] -= a;
				if(p[o[i]] <= 0 && ans[o[i]] == -1){
					ans[o[i]] = cnt;
				}
			}
		}
	}
	for(int i = 1; i <= n; ++i){
		if(ans[i] == -1) cout << "NIE\n";
		else cout << ans[i] << '\n';
	}
}











# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2636 KB Output is correct
2 Correct 3 ms 2636 KB Output is correct
3 Correct 4 ms 2636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2636 KB Output is correct
2 Correct 4 ms 2636 KB Output is correct
3 Correct 3 ms 2636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1793 ms 3112 KB Output is correct
2 Correct 5298 ms 3276 KB Output is correct
3 Correct 3203 ms 3164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2045 ms 3148 KB Output is correct
2 Correct 2481 ms 3268 KB Output is correct
3 Execution timed out 6012 ms 3276 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3562 ms 3100 KB Output is correct
2 Correct 4388 ms 3276 KB Output is correct
3 Correct 47 ms 2636 KB Output is correct
4 Correct 2415 ms 3196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5870 ms 3068 KB Output is correct
2 Execution timed out 6086 ms 3148 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 6084 ms 5752 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 6074 ms 5572 KB Time limit exceeded
2 Halted 0 ms 0 KB -