Submission #111770

# Submission time Handle Problem Language Result Execution time Memory
111770 2019-05-16T06:34:20 Z Evirir Two Antennas (JOI19_antennas) C++17
13 / 100
160 ms 63484 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<endl
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265358979323846264338327
#define INF 0x3f3f3f3f
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 2005

int n,q;
ll h[MAXN],a[MAXN],b[MAXN];
ll dp[MAXN][MAXN];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	mset(dp,-1);
	
	cin>>n;
	forn(i,0,n){
		cin>>h[i]>>a[i]>>b[i];
	}
	
	forn(d,1,n){
		forn(i,0,n-d){
			int j=i+d;
			dp[i][j]=max(dp[i+1][j],dp[i][j-1]);
			if(a[i]<=d && d<=b[i] && a[j]<=d && d<=b[j]){
				dp[i][j]=max(dp[i][j],abs(h[i]-h[j]));
			}
		}
	}
	
	cin>>q;
	forn(it,0,q){
		int s,e; cin>>s>>e; s--; e--;
		cout<<dp[s][e]<<'\n';
	}
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 25 ms 31744 KB Output is correct
2 Correct 27 ms 31864 KB Output is correct
3 Correct 27 ms 31872 KB Output is correct
4 Correct 26 ms 31872 KB Output is correct
5 Correct 28 ms 31744 KB Output is correct
6 Correct 27 ms 31872 KB Output is correct
7 Correct 27 ms 31872 KB Output is correct
8 Correct 27 ms 31864 KB Output is correct
9 Correct 27 ms 31872 KB Output is correct
10 Correct 30 ms 31872 KB Output is correct
11 Correct 34 ms 31736 KB Output is correct
12 Correct 27 ms 31872 KB Output is correct
13 Correct 25 ms 31868 KB Output is correct
14 Correct 26 ms 31736 KB Output is correct
15 Correct 30 ms 31864 KB Output is correct
16 Correct 34 ms 32000 KB Output is correct
17 Correct 26 ms 31744 KB Output is correct
18 Correct 29 ms 31872 KB Output is correct
19 Correct 25 ms 31744 KB Output is correct
20 Correct 37 ms 31864 KB Output is correct
21 Correct 33 ms 31744 KB Output is correct
22 Correct 29 ms 31752 KB Output is correct
23 Correct 26 ms 31872 KB Output is correct
24 Correct 30 ms 31744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 31744 KB Output is correct
2 Correct 27 ms 31864 KB Output is correct
3 Correct 27 ms 31872 KB Output is correct
4 Correct 26 ms 31872 KB Output is correct
5 Correct 28 ms 31744 KB Output is correct
6 Correct 27 ms 31872 KB Output is correct
7 Correct 27 ms 31872 KB Output is correct
8 Correct 27 ms 31864 KB Output is correct
9 Correct 27 ms 31872 KB Output is correct
10 Correct 30 ms 31872 KB Output is correct
11 Correct 34 ms 31736 KB Output is correct
12 Correct 27 ms 31872 KB Output is correct
13 Correct 25 ms 31868 KB Output is correct
14 Correct 26 ms 31736 KB Output is correct
15 Correct 30 ms 31864 KB Output is correct
16 Correct 34 ms 32000 KB Output is correct
17 Correct 26 ms 31744 KB Output is correct
18 Correct 29 ms 31872 KB Output is correct
19 Correct 25 ms 31744 KB Output is correct
20 Correct 37 ms 31864 KB Output is correct
21 Correct 33 ms 31744 KB Output is correct
22 Correct 29 ms 31752 KB Output is correct
23 Correct 26 ms 31872 KB Output is correct
24 Correct 30 ms 31744 KB Output is correct
25 Correct 75 ms 32988 KB Output is correct
26 Correct 52 ms 32120 KB Output is correct
27 Correct 125 ms 34652 KB Output is correct
28 Correct 116 ms 34680 KB Output is correct
29 Correct 94 ms 34168 KB Output is correct
30 Correct 106 ms 34168 KB Output is correct
31 Correct 115 ms 34436 KB Output is correct
32 Correct 127 ms 34684 KB Output is correct
33 Correct 109 ms 34552 KB Output is correct
34 Correct 88 ms 33576 KB Output is correct
35 Correct 128 ms 34680 KB Output is correct
36 Correct 160 ms 34680 KB Output is correct
37 Correct 87 ms 33400 KB Output is correct
38 Correct 111 ms 33856 KB Output is correct
39 Correct 46 ms 32248 KB Output is correct
40 Correct 111 ms 33756 KB Output is correct
41 Correct 97 ms 33528 KB Output is correct
42 Correct 109 ms 33696 KB Output is correct
43 Correct 65 ms 32760 KB Output is correct
44 Correct 121 ms 33760 KB Output is correct
45 Correct 65 ms 32376 KB Output is correct
46 Correct 134 ms 33784 KB Output is correct
47 Correct 59 ms 32504 KB Output is correct
48 Correct 132 ms 33756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 66 ms 63484 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 25 ms 31744 KB Output is correct
2 Correct 27 ms 31864 KB Output is correct
3 Correct 27 ms 31872 KB Output is correct
4 Correct 26 ms 31872 KB Output is correct
5 Correct 28 ms 31744 KB Output is correct
6 Correct 27 ms 31872 KB Output is correct
7 Correct 27 ms 31872 KB Output is correct
8 Correct 27 ms 31864 KB Output is correct
9 Correct 27 ms 31872 KB Output is correct
10 Correct 30 ms 31872 KB Output is correct
11 Correct 34 ms 31736 KB Output is correct
12 Correct 27 ms 31872 KB Output is correct
13 Correct 25 ms 31868 KB Output is correct
14 Correct 26 ms 31736 KB Output is correct
15 Correct 30 ms 31864 KB Output is correct
16 Correct 34 ms 32000 KB Output is correct
17 Correct 26 ms 31744 KB Output is correct
18 Correct 29 ms 31872 KB Output is correct
19 Correct 25 ms 31744 KB Output is correct
20 Correct 37 ms 31864 KB Output is correct
21 Correct 33 ms 31744 KB Output is correct
22 Correct 29 ms 31752 KB Output is correct
23 Correct 26 ms 31872 KB Output is correct
24 Correct 30 ms 31744 KB Output is correct
25 Correct 75 ms 32988 KB Output is correct
26 Correct 52 ms 32120 KB Output is correct
27 Correct 125 ms 34652 KB Output is correct
28 Correct 116 ms 34680 KB Output is correct
29 Correct 94 ms 34168 KB Output is correct
30 Correct 106 ms 34168 KB Output is correct
31 Correct 115 ms 34436 KB Output is correct
32 Correct 127 ms 34684 KB Output is correct
33 Correct 109 ms 34552 KB Output is correct
34 Correct 88 ms 33576 KB Output is correct
35 Correct 128 ms 34680 KB Output is correct
36 Correct 160 ms 34680 KB Output is correct
37 Correct 87 ms 33400 KB Output is correct
38 Correct 111 ms 33856 KB Output is correct
39 Correct 46 ms 32248 KB Output is correct
40 Correct 111 ms 33756 KB Output is correct
41 Correct 97 ms 33528 KB Output is correct
42 Correct 109 ms 33696 KB Output is correct
43 Correct 65 ms 32760 KB Output is correct
44 Correct 121 ms 33760 KB Output is correct
45 Correct 65 ms 32376 KB Output is correct
46 Correct 134 ms 33784 KB Output is correct
47 Correct 59 ms 32504 KB Output is correct
48 Correct 132 ms 33756 KB Output is correct
49 Runtime error 66 ms 63484 KB Execution killed with signal 11 (could be triggered by violating memory limits)
50 Halted 0 ms 0 KB -