Submission #524546

# Submission time Handle Problem Language Result Execution time Memory
524546 2022-02-09T13:14:09 Z asliddinaif Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
64 / 100
134 ms 13756 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
#define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
#define fm(a,i,c) for(int (a) = (i); (a) > (c); (a)--)
#define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--)
const int maxx = 2e5+5;
int tr[maxx], n, m, a[maxx], ans[maxx], k[maxx], x[maxx], y[maxx];
vector <int> g[maxx];
void ad(int x, int val){
	while(x > 0)
		tr[x] = max(tr[x], val), x -= x & -x;
}

int get(int x){
	int s = 0;
	while(x <= n)
		s = max(tr[x], s), x += x & -x;
	return s;
}
void S()
{
	cin >> n >> m;
	fpp(i,1,n)
		cin >> a[i];
	fpp(i,1,m){
		cin >> x[i] >> y[i] >> k[i];
		g[y[i]].push_back(i);
	}
	vector <int> v;
	fpp(i,1,n){
		while(!v.empty() && a[v.back()] <= a[i])
			v.pop_back();
		int xx = (v.size() == 0 ? 0 : v.back());
		ad(xx, a[xx]+a[i]);
		for(auto it : g[i])
			ans[it] = (get(x[it]) <= k[it]);//, cout << get(x[it]) << " " << i << " " << it << " ";
		v.push_back(i);
	//	cout << a[xx] << "\n";
	}
	fpp(i,1,m)
		cout << ans[i] << "\n";
}
int main()
{
	IOS;
	S();
}

Compilation message

sortbooks.cpp: In function 'void S()':
sortbooks.cpp:7:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    7 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
sortbooks.cpp:27:2: note: in expansion of macro 'fpp'
   27 |  fpp(i,1,n)
      |  ^~~
sortbooks.cpp:7:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    7 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
sortbooks.cpp:29:2: note: in expansion of macro 'fpp'
   29 |  fpp(i,1,m){
      |  ^~~
sortbooks.cpp:7:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    7 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
sortbooks.cpp:34:2: note: in expansion of macro 'fpp'
   34 |  fpp(i,1,n){
      |  ^~~
sortbooks.cpp:7:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    7 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
sortbooks.cpp:44:2: note: in expansion of macro 'fpp'
   44 |  fpp(i,1,m)
      |  ^~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 4 ms 5028 KB Output is correct
4 Correct 3 ms 5020 KB Output is correct
5 Correct 3 ms 5024 KB Output is correct
6 Correct 3 ms 5068 KB Output is correct
7 Correct 3 ms 5068 KB Output is correct
8 Correct 3 ms 5068 KB Output is correct
9 Correct 3 ms 5024 KB Output is correct
10 Correct 3 ms 5068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 4 ms 5028 KB Output is correct
4 Correct 3 ms 5020 KB Output is correct
5 Correct 3 ms 5024 KB Output is correct
6 Correct 3 ms 5068 KB Output is correct
7 Correct 3 ms 5068 KB Output is correct
8 Correct 3 ms 5068 KB Output is correct
9 Correct 3 ms 5024 KB Output is correct
10 Correct 3 ms 5068 KB Output is correct
11 Correct 4 ms 5160 KB Output is correct
12 Correct 5 ms 5252 KB Output is correct
13 Correct 4 ms 5196 KB Output is correct
14 Correct 5 ms 5404 KB Output is correct
15 Correct 5 ms 5324 KB Output is correct
16 Correct 5 ms 5324 KB Output is correct
17 Correct 4 ms 5276 KB Output is correct
18 Correct 5 ms 5324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 45 ms 13636 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 56 ms 9688 KB Output is correct
2 Correct 50 ms 8856 KB Output is correct
3 Correct 51 ms 9012 KB Output is correct
4 Correct 49 ms 9140 KB Output is correct
5 Correct 51 ms 9208 KB Output is correct
6 Correct 49 ms 8232 KB Output is correct
7 Correct 42 ms 8244 KB Output is correct
8 Correct 52 ms 9116 KB Output is correct
9 Correct 34 ms 7768 KB Output is correct
10 Correct 48 ms 9100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 4 ms 5028 KB Output is correct
4 Correct 3 ms 5020 KB Output is correct
5 Correct 3 ms 5024 KB Output is correct
6 Correct 3 ms 5068 KB Output is correct
7 Correct 3 ms 5068 KB Output is correct
8 Correct 3 ms 5068 KB Output is correct
9 Correct 3 ms 5024 KB Output is correct
10 Correct 3 ms 5068 KB Output is correct
11 Correct 4 ms 5160 KB Output is correct
12 Correct 5 ms 5252 KB Output is correct
13 Correct 4 ms 5196 KB Output is correct
14 Correct 5 ms 5404 KB Output is correct
15 Correct 5 ms 5324 KB Output is correct
16 Correct 5 ms 5324 KB Output is correct
17 Correct 4 ms 5276 KB Output is correct
18 Correct 5 ms 5324 KB Output is correct
19 Correct 134 ms 13740 KB Output is correct
20 Correct 126 ms 13756 KB Output is correct
21 Correct 113 ms 12100 KB Output is correct
22 Correct 109 ms 12100 KB Output is correct
23 Correct 115 ms 12112 KB Output is correct
24 Correct 100 ms 11088 KB Output is correct
25 Correct 108 ms 11204 KB Output is correct
26 Correct 110 ms 11880 KB Output is correct
27 Correct 108 ms 11888 KB Output is correct
28 Correct 115 ms 12176 KB Output is correct
29 Correct 133 ms 12980 KB Output is correct
30 Correct 125 ms 12996 KB Output is correct
31 Correct 121 ms 12976 KB Output is correct
32 Correct 117 ms 13052 KB Output is correct
33 Correct 117 ms 12908 KB Output is correct
34 Correct 98 ms 10980 KB Output is correct
35 Correct 105 ms 10900 KB Output is correct
36 Correct 92 ms 10948 KB Output is correct
37 Correct 91 ms 10976 KB Output is correct
38 Correct 102 ms 10972 KB Output is correct
39 Correct 107 ms 12960 KB Output is correct
40 Correct 93 ms 12088 KB Output is correct
41 Correct 105 ms 12820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 4 ms 5028 KB Output is correct
4 Correct 3 ms 5020 KB Output is correct
5 Correct 3 ms 5024 KB Output is correct
6 Correct 3 ms 5068 KB Output is correct
7 Correct 3 ms 5068 KB Output is correct
8 Correct 3 ms 5068 KB Output is correct
9 Correct 3 ms 5024 KB Output is correct
10 Correct 3 ms 5068 KB Output is correct
11 Correct 4 ms 5160 KB Output is correct
12 Correct 5 ms 5252 KB Output is correct
13 Correct 4 ms 5196 KB Output is correct
14 Correct 5 ms 5404 KB Output is correct
15 Correct 5 ms 5324 KB Output is correct
16 Correct 5 ms 5324 KB Output is correct
17 Correct 4 ms 5276 KB Output is correct
18 Correct 5 ms 5324 KB Output is correct
19 Runtime error 45 ms 13636 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -