Submission #1799980
Source Code Expand
#include <iostream> #include <cstring> using namespace std; int n, mx, mn, a[1005], d[1005][1005]; int abs(int p) {return p>0?p:-p;} int f(int p, int q) { int i; if(p==n+1 || q==n+1) return d[p][q] = abs(a[p]-a[q]); if(d[p][q]!=-1) return d[p][q]; if(p<q) { mx = -1; for(i=q+1; i<n+2; i++) mx = max(mx, f(i, q)); d[i][q] = mx; } else { mn = 2e9; for(i=p+1; i<n+2; i++) mn = min(mn, f(p, i)); d[p][i] = mn; } } int main() { cin>>n>>a[0]>>a[1]; for(int i=2; i<n+2; i++) cin>>a[i]; memset(d, -1, sizeof(d)); cout<<f(0, 1); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - ABS |
User | t1234 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 586 Byte |
Status | RE |
Exec Time | 2104 ms |
Memory | 4224 KB |
Judge Result
Set Name | Sample | All | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 500 | ||||||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example_0, example_1, example_2, example_3 |
All | example_0, example_1, example_2, example_3, one_0, one_1, one_2, one_3, one_4, one_5, one_6, one_7, rand_0, rand_1, rand_10, rand_11, rand_12, rand_13, rand_14, rand_15, rand_2, rand_3, rand_4, rand_5, rand_6, rand_7, rand_8, rand_9 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
example_0 | WA | 3 ms | 4224 KB |
example_1 | WA | 3 ms | 4224 KB |
example_2 | AC | 3 ms | 4224 KB |
example_3 | WA | 3 ms | 4224 KB |
one_0 | WA | 3 ms | 4224 KB |
one_1 | WA | 3 ms | 4224 KB |
one_2 | WA | 3 ms | 4224 KB |
one_3 | WA | 3 ms | 4224 KB |
one_4 | WA | 3 ms | 4224 KB |
one_5 | WA | 3 ms | 4224 KB |
one_6 | WA | 3 ms | 4224 KB |
one_7 | WA | 3 ms | 4224 KB |
rand_0 | RE | 99 ms | 256 KB |
rand_1 | TLE | 2103 ms | 4224 KB |
rand_10 | RE | 99 ms | 256 KB |
rand_11 | TLE | 2104 ms | 4224 KB |
rand_12 | RE | 99 ms | 256 KB |
rand_13 | RE | 100 ms | 256 KB |
rand_14 | RE | 100 ms | 256 KB |
rand_15 | TLE | 2103 ms | 4224 KB |
rand_2 | RE | 98 ms | 256 KB |
rand_3 | RE | 99 ms | 256 KB |
rand_4 | RE | 101 ms | 256 KB |
rand_5 | TLE | 2103 ms | 256 KB |
rand_6 | RE | 98 ms | 256 KB |
rand_7 | TLE | 2103 ms | 256 KB |
rand_8 | RE | 100 ms | 256 KB |
rand_9 | RE | 100 ms | 256 KB |