답안 #496311

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
496311 2021-12-21T05:28:25 Z Ierus Meteors (POI11_met) C++17
49 / 100
6000 ms 3000 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 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 2 ms 1484 KB Output is correct
2 Correct 2 ms 1484 KB Output is correct
3 Correct 3 ms 1484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1484 KB Output is correct
2 Correct 3 ms 1484 KB Output is correct
3 Correct 3 ms 1484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1933 ms 1716 KB Output is correct
2 Correct 5595 ms 1796 KB Output is correct
3 Correct 3328 ms 1744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2279 ms 1740 KB Output is correct
2 Correct 2818 ms 1740 KB Output is correct
3 Execution timed out 6068 ms 1740 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3866 ms 1712 KB Output is correct
2 Correct 4742 ms 1784 KB Output is correct
3 Correct 48 ms 1484 KB Output is correct
4 Correct 2523 ms 1764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 6083 ms 1612 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 6079 ms 2992 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 6099 ms 3000 KB Time limit exceeded
2 Halted 0 ms 0 KB -