Submission #496227

# Submission time Handle Problem Language Result Execution time Memory
496227 2021-12-21T03:27:16 Z mansur Meteors (POI11_met) C++17
74 / 100
6000 ms 1868 KB
#include<bits/stdc++.h>	
 
#pragma optimize ("g",on)
#pragma GCC optimize ("inline")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("03")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native")
#pragma comment(linker, "/stack:200000000")

//01001101 01100001 01101011 01101000 01100001  01100111 01100001 01111001 

using namespace std;

#define all(a) a.begin(), a.end()                                                   
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define pb push_back
#define sz(a) a.size()
#define nl '\n'
#define popb pop_back()                                                                   
#define ld double
#define ull unsigned long long
#define ff first                                         
#define ss second  
#define fix fixed << setprecision
#define pii pair<int, int>                          
#define E exit (0)
 
const int inf = 1e9, N = 1e6 + 1, mod = 998244353;                    

vector<pii> dir = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

int ans[N];

main() {                                                         
	//freopen("cowrect.in", "r", stdin);                                                                                     
	//freopen("cowrect.out", "w", stdout);                                                                                     
	ios_base::sync_with_stdio(NULL);                                                                                        
	cin.tie(NULL);
	int n, m;
	cin >> n >> m;
	int a[m + 1], b[n + 1];
	for (int i = 1; i <= m; i++) cin >> a[i];   
	for (int i = 1; i <= n; i++) cin >> b[i];
	int k;
	cin >> k;
	for (int i = 1; i <= k; i++) {
		int l, r, x;
		cin >> l >> r >> x;
		if (l <= r) {
			for (int j = l; j <= r; j++) {
				if (b[a[j]] && b[a[j]] <= x) {
					b[a[j]] = 0;
					ans[a[j]] = i; 	
				}else if(b[a[j]]) b[a[j]] -= x;	
			}
		}else {
			for (int j = l; j <= m; j++) {
				if (b[a[j]] && b[a[j]] <= x) {
					b[a[j]] = 0;
					ans[a[j]] = i; 	
				}else if(b[a[j]]) b[a[j]] -= x;	
			}
			for (int j = 1; j <= r; j++) {
				if (b[a[j]] && b[a[j]] <= x) {
					b[a[j]] = 0;
					ans[a[j]] = i; 	
				}else if(b[a[j]]) b[a[j]] -= x;	
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		if (ans[i] == 0) cout << "NIE" << nl;
		else cout << ans[i] << nl;
	}
}

Compilation message

met.cpp:3: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    3 | #pragma optimize ("g",on)
      | 
met.cpp:9: warning: ignoring '#pragma comment ' [-Wunknown-pragmas]
    9 | #pragma comment(linker, "/stack:200000000")
      | 
met.cpp:36:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   36 | main() {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 3 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 317 ms 580 KB Output is correct
2 Correct 5442 ms 880 KB Output is correct
3 Correct 2664 ms 708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1474 ms 564 KB Output is correct
2 Correct 1932 ms 580 KB Output is correct
3 Correct 1139 ms 688 KB Output is correct
4 Correct 12 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1755 ms 772 KB Output is correct
2 Correct 4231 ms 696 KB Output is correct
3 Correct 28 ms 204 KB Output is correct
4 Correct 1875 ms 628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1890 ms 496 KB Output is correct
2 Correct 3669 ms 572 KB Output is correct
3 Correct 1418 ms 508 KB Output is correct
4 Correct 4770 ms 816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 6028 ms 1868 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 6020 ms 1740 KB Time limit exceeded
2 Halted 0 ms 0 KB -