Submission #865114

# Submission time Handle Problem Language Result Execution time Memory
865114 2023-10-24T05:39:34 Z vjudge1 Meteors (POI11_met) C++17
74 / 100
6000 ms 12884 KB
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef long double ld;

#define all(x) x.begin(),x.end()
#define pb push_back
#define ent "\n"

const int maxn = (int)3e5 + 13;
const ll inf = (long long)1e18 + 20;
const int mod = (int)1e9 + 7;

int n,m;
int a[maxn],b[maxn];
int l[maxn],r[maxn],w[maxn],res[maxn];
ll sum[maxn];

void solve(){
	cin >> n >> m;
	for(int i = 1 ; i <= m ; i ++){
		cin >> a[i];
	}
	for(int i = 1 ; i <= n ; i ++){
		cin >> b[i];
	}
	int q;cin >> q;
	for(int i = 1 ; i <= q ; i ++){
		cin >> l[i] >> r[i] >> w[i];
	}
	for(int i = 1 ; i <= q ; i ++){
		if(l[i] <= r[i]){
			for(int j = l[i] ; j <= r[i] ; j ++){
				sum[a[j]] += w[i] * 1ll;
				if(sum[a[j]] >= b[a[j]]){
					if(!res[a[j]]){
						res[a[j]] = i;
					}
				}
			}
		}
		else{
			for(int j = l[i] ; j <= m ; j ++){
				sum[a[j]]+=w[i] * 1ll;
				if(sum[a[j]] >= b[a[j]]){
					if(!res[a[j]]){
						res[a[j]] = i;
					}
				}
			}
			for(int j = 1 ; j <= r[i] ; j ++){
				sum[a[j]]+=w[i] * 1ll;
				if(sum[a[j]] >= b[a[j]]){
					if(!res[a[j]]){
						res[a[j]] = i;
					}
				}
			}
		}
	}
	for(int i = 1 ; i <= n ; i ++){
		if(res[i] == 0){
			cout << "NIE\n";
		}
		else{
			cout << res[i] << ent;
		}
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	while(t --){
		solve();
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1521 ms 6624 KB Output is correct
2 Correct 2276 ms 6776 KB Output is correct
3 Correct 2397 ms 6736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1160 ms 6696 KB Output is correct
2 Correct 2001 ms 6692 KB Output is correct
3 Correct 3417 ms 6820 KB Output is correct
4 Correct 11 ms 6748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2011 ms 6900 KB Output is correct
2 Correct 2277 ms 6832 KB Output is correct
3 Correct 23 ms 6492 KB Output is correct
4 Correct 1846 ms 6764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2986 ms 6652 KB Output is correct
2 Correct 4406 ms 6696 KB Output is correct
3 Correct 1112 ms 6740 KB Output is correct
4 Correct 4083 ms 6820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 6029 ms 12884 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 6027 ms 8020 KB Time limit exceeded
2 Halted 0 ms 0 KB -