Submission #496356

# Submission time Handle Problem Language Result Execution time Memory
496356 2021-12-21T06:18:16 Z vinnipuh01 Meteors (POI11_met) C++17
74 / 100
6000 ms 1828 KB
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <string>
#include <map>
#include <queue>

using namespace std;

const long long oo = 1000000000000000000;

long long int  sum, ans = 0, mx = 0, mn = 1000000000, num, pos;


/*
    ViHHiPuh

   (( `'-""``""-'` ))
     )-__-_.._-__-(
   / --- (o _ o) --- \
   \ .-* ( .0. ) *-. /
   _'-. ,_ '=' _, .-'_
  / `;#'#'# - #'#'#;` \
 \_)) -----'#'----- ((_/
      # --------- #
  '# ------- ------ #'
  /..-'# ------- #'-.\
  _\...-\'# -- #'/-.../_
  ((____)- '#' -(____))


    cout << fixed << setprecision(6) << x;

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    freopen ( "sum.in", "r", stdin )
*/

int mp[ 300001 ];

int main () {
	int n, m;
	cin >> n >> m;
	int a[ m + 1 ];
	for ( int i = 1; i <= m; i ++ )
		cin >> a[ i ];
	int b[ n + 1 ];
	for ( int i = 1; i <= n; i ++ ) {
		cin >> b[ i ];
	}
	int q, l, r, x;
	cin >> q;
	while ( q -- ) {
		num ++;
		cin >> l >> r >> x;
		if ( l > r ) {
			for ( int i = l; i <= m; i ++ ) {
				if ( b[ a[ i ] ] <= 0 )
					continue;
				b[ a[ i ] ] -= x;
				if ( b[ a[ i ] ] <= 0 )
					mp[ a[ i ] ] = num;
			}
			for ( int i = 1; i <= r; i ++ ) {
				if ( b[ a[ i ] ] <= 0 )
					continue;
				b[ a[ i ] ] -= x;
				if ( b[ a[ i ] ] <= 0 )
					mp[ a[ i ] ] = num;
			}
		}
		else {
			for ( int i = l; i <= r; i ++ ) {
				if ( b[ a[ i ] ] <= 0 )
					continue;
				b[ a[ i ] ] -= x;
				if ( b[ a[ i ] ] <= 0 )
					mp[ a[ i ] ] = num;
			}
		}
	}
	for ( int i = 1; i <= n; i ++ ) {
		if ( !mp[ i ] )
			cout << "NIE\n";
		else
			cout << mp[ i ] << "\n";
	}
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 2 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 2 ms 204 KB Output is correct
3 Correct 3 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 711 ms 492 KB Output is correct
2 Correct 5473 ms 696 KB Output is correct
3 Correct 2876 ms 572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1590 ms 536 KB Output is correct
2 Correct 2166 ms 632 KB Output is correct
3 Correct 1578 ms 660 KB Output is correct
4 Correct 25 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2212 ms 508 KB Output is correct
2 Correct 4516 ms 664 KB Output is correct
3 Correct 46 ms 276 KB Output is correct
4 Correct 2088 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2335 ms 472 KB Output is correct
2 Correct 4429 ms 544 KB Output is correct
3 Correct 1611 ms 604 KB Output is correct
4 Correct 5428 ms 788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 6065 ms 1828 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 6068 ms 1708 KB Time limit exceeded
2 Halted 0 ms 0 KB -