Submission #865068

# Submission time Handle Problem Language Result Execution time Memory
865068 2023-10-24T05:10:10 Z vjudge1 Meteors (POI11_met) C++17
24 / 100
6000 ms 22268 KB
#include <bits/stdc++.h>
 
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define optimus_prime ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fxd(x) fixed << setprecision(x)
#define all(a) (a.begin() , a.end())
#define popcount(x) __builtin_popcount(x)
#define lwb lower_bound
#define upb upper_bound
#define dl double long
#define ll long long
#define pb push_back
#define sz() size()
#define F first
#define S second
 
using namespace std;
 
const ll N = 3e5+9;
const ll inf=1e9+9;
const ll mod=1e9+7;
const ll P = 37;

map <int , int> mp;

ll n , m , q , p[N] , a[N] , ans[N] , sum[N] , timer;

void solve(){
	cin >> n >> m;
	for (int i = 1 ; i <= m ; i++){
		cin >> p[i];
		mp[i]=p[i];
	}
	for (int i = 1 ; i <= n ; i++)cin >> a[i];
	cin >> q;
	while (q--){
		timer++;
		ll l , r , x;
		cin >> l >> r >> x;
		if (l<=r){
			for (int i = l ; i <= r ; i++){
				sum[mp[i]]+=x;
				if (sum[mp[i]]>=a[mp[i]]&&!ans[mp[i]]){
					ans[mp[i]]=timer;
				}
			}
		}
		else {
			for (int i = l ; i <= m ; i++){
				sum[mp[i]]+=x;
				if (sum[mp[i]]>=a[mp[i]]&&!ans[mp[i]]){
					ans[mp[i]]=timer;
				}
			}
			for (int i = 1 ; i <= r ; i++){
				sum[mp[i]]+=x;
				if (sum[mp[i]]>=a[mp[i]]&&!ans[mp[i]]){
					ans[mp[i]]=timer;
				}
			}
		}
	}
	for (int i = 1;  i<= n ; i++){
		if (!ans[i])cout << "NIE\n";
		else cout << ans[i] << "\n";
	}
}
	
signed main() {
	optimus_prime;
	ll t=1;
	while (t--)solve();
return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 34 ms 4444 KB Output is correct
2 Correct 43 ms 4444 KB Output is correct
3 Correct 67 ms 4596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 4604 KB Output is correct
2 Correct 70 ms 4604 KB Output is correct
3 Correct 64 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 6019 ms 6744 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 6051 ms 7024 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 6063 ms 6912 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 6059 ms 6748 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 6022 ms 22096 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 6041 ms 22268 KB Time limit exceeded
2 Halted 0 ms 0 KB -