Submission #112054

# Submission time Handle Problem Language Result Execution time Memory
112054 2019-05-17T08:04:14 Z lauzm0 Two Antennas (JOI19_antennas) C++14
13 / 100
1353 ms 524288 KB
#include <iostream>
#include<vector>
#include<cmath>
 
using namespace std;
 
struct antenna {
	int l; int r; long long h;
};
 
int main()
{
	int n;
	cin >> n;
	vector<antenna> ant(n); vector<vector<int> >max(n,vector<int>(n,-1));
	for (int i = 0; i < n; i++) {
		cin >> ant[i].h >> ant[i].l >> ant[i].r;
	}

	for(int a = 0 ; a< n-1 ; a++){
		int mxx = -1;
		for(int b = a+1 ; b<n ; b++){
			bool rangealeft = false; bool rangearight = false; bool rangebleft = false; bool rangebright = false;
 
				if (a - ant[a].l >= b && a - ant[a].r <= b) {
					rangealeft = true;
				}
				if (b - ant[b].l >= a && b - ant[b].r <= a) {
					rangebleft = true;
				}
				if (a + ant[a ].l <= b && a + ant[a].r >= b) {
					rangearight = true;
				}
				if (b + ant[b].l <= a && b + ant[b].r >= a) {
					rangebright = true;
				}
				if ((rangealeft||rangearight)&&(rangebleft||rangebright)) {
					if (abs(ant[a ].h - ant[b ].h) > mxx) {
						mxx= abs(ant[a ].h - ant[b ].h);
					}
				}
				max[a][b]=mxx;
		}
	}

	

	int q ; cin>>q; 
	for(int i = 0 ; i< q ; i++){
		int l ; int r; int maxima=-1;
		cin>>l>>r;
		for(int j = l ; j< r ; j++){
			if(max[j-1][r-1]>maxima){
				maxima=max[j-1][r-1];
			}
		}
		cout<<maxima<<endl;
		
	}

	

}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 640 KB Output is correct
3 Correct 3 ms 512 KB Output is correct
4 Correct 3 ms 640 KB Output is correct
5 Correct 3 ms 640 KB Output is correct
6 Correct 3 ms 640 KB Output is correct
7 Correct 3 ms 640 KB Output is correct
8 Correct 3 ms 768 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 768 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 768 KB Output is correct
13 Correct 3 ms 640 KB Output is correct
14 Correct 4 ms 640 KB Output is correct
15 Correct 3 ms 640 KB Output is correct
16 Correct 3 ms 640 KB Output is correct
17 Correct 3 ms 640 KB Output is correct
18 Correct 3 ms 512 KB Output is correct
19 Correct 2 ms 640 KB Output is correct
20 Correct 1 ms 640 KB Output is correct
21 Correct 3 ms 512 KB Output is correct
22 Correct 3 ms 640 KB Output is correct
23 Correct 3 ms 640 KB Output is correct
24 Correct 3 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 640 KB Output is correct
3 Correct 3 ms 512 KB Output is correct
4 Correct 3 ms 640 KB Output is correct
5 Correct 3 ms 640 KB Output is correct
6 Correct 3 ms 640 KB Output is correct
7 Correct 3 ms 640 KB Output is correct
8 Correct 3 ms 768 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 768 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 768 KB Output is correct
13 Correct 3 ms 640 KB Output is correct
14 Correct 4 ms 640 KB Output is correct
15 Correct 3 ms 640 KB Output is correct
16 Correct 3 ms 640 KB Output is correct
17 Correct 3 ms 640 KB Output is correct
18 Correct 3 ms 512 KB Output is correct
19 Correct 2 ms 640 KB Output is correct
20 Correct 1 ms 640 KB Output is correct
21 Correct 3 ms 512 KB Output is correct
22 Correct 3 ms 640 KB Output is correct
23 Correct 3 ms 640 KB Output is correct
24 Correct 3 ms 640 KB Output is correct
25 Correct 380 ms 5796 KB Output is correct
26 Correct 106 ms 16376 KB Output is correct
27 Correct 1187 ms 14608 KB Output is correct
28 Correct 1353 ms 19808 KB Output is correct
29 Correct 438 ms 6412 KB Output is correct
30 Correct 991 ms 18488 KB Output is correct
31 Correct 379 ms 3472 KB Output is correct
32 Correct 1209 ms 19704 KB Output is correct
33 Correct 576 ms 9268 KB Output is correct
34 Correct 633 ms 17924 KB Output is correct
35 Correct 856 ms 12352 KB Output is correct
36 Correct 1181 ms 19868 KB Output is correct
37 Correct 623 ms 16944 KB Output is correct
38 Correct 1146 ms 18160 KB Output is correct
39 Correct 159 ms 15864 KB Output is correct
40 Correct 1112 ms 18144 KB Output is correct
41 Correct 805 ms 17400 KB Output is correct
42 Correct 1090 ms 18172 KB Output is correct
43 Correct 362 ms 16120 KB Output is correct
44 Correct 1099 ms 18048 KB Output is correct
45 Correct 204 ms 15984 KB Output is correct
46 Correct 1238 ms 18128 KB Output is correct
47 Correct 283 ms 16172 KB Output is correct
48 Correct 1279 ms 18172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 377 ms 524288 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 640 KB Output is correct
3 Correct 3 ms 512 KB Output is correct
4 Correct 3 ms 640 KB Output is correct
5 Correct 3 ms 640 KB Output is correct
6 Correct 3 ms 640 KB Output is correct
7 Correct 3 ms 640 KB Output is correct
8 Correct 3 ms 768 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 768 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 768 KB Output is correct
13 Correct 3 ms 640 KB Output is correct
14 Correct 4 ms 640 KB Output is correct
15 Correct 3 ms 640 KB Output is correct
16 Correct 3 ms 640 KB Output is correct
17 Correct 3 ms 640 KB Output is correct
18 Correct 3 ms 512 KB Output is correct
19 Correct 2 ms 640 KB Output is correct
20 Correct 1 ms 640 KB Output is correct
21 Correct 3 ms 512 KB Output is correct
22 Correct 3 ms 640 KB Output is correct
23 Correct 3 ms 640 KB Output is correct
24 Correct 3 ms 640 KB Output is correct
25 Correct 380 ms 5796 KB Output is correct
26 Correct 106 ms 16376 KB Output is correct
27 Correct 1187 ms 14608 KB Output is correct
28 Correct 1353 ms 19808 KB Output is correct
29 Correct 438 ms 6412 KB Output is correct
30 Correct 991 ms 18488 KB Output is correct
31 Correct 379 ms 3472 KB Output is correct
32 Correct 1209 ms 19704 KB Output is correct
33 Correct 576 ms 9268 KB Output is correct
34 Correct 633 ms 17924 KB Output is correct
35 Correct 856 ms 12352 KB Output is correct
36 Correct 1181 ms 19868 KB Output is correct
37 Correct 623 ms 16944 KB Output is correct
38 Correct 1146 ms 18160 KB Output is correct
39 Correct 159 ms 15864 KB Output is correct
40 Correct 1112 ms 18144 KB Output is correct
41 Correct 805 ms 17400 KB Output is correct
42 Correct 1090 ms 18172 KB Output is correct
43 Correct 362 ms 16120 KB Output is correct
44 Correct 1099 ms 18048 KB Output is correct
45 Correct 204 ms 15984 KB Output is correct
46 Correct 1238 ms 18128 KB Output is correct
47 Correct 283 ms 16172 KB Output is correct
48 Correct 1279 ms 18172 KB Output is correct
49 Runtime error 377 ms 524288 KB Execution killed with signal 9 (could be triggered by violating memory limits)
50 Halted 0 ms 0 KB -