# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
811568 | 2023-08-07T04:56:45 Z | vjudge1 | 3단 점프 (JOI19_jumps) | C++17 | 4000 ms | 323284 KB |
#include <bits/stdc++.h> using namespace std; #define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define rall(s) s.rbegin(),s.rend() #define all(s) s.begin(),s.end() #define pb push_back #define fi first #define se second #define ll long long #define ld long double #define YES cout<<"YES\n" #define Yes cout<<"Yes\n" #define yes cout<<"yes\n" #define NO cout<<"NO\n" #define No cout<<"No\n" #define no cout<<"no\n" const int N = 5e5 + 9 , mod = 1e9 + 7; ll d[N] = {} , a[N] = {}, dp[5009][5009] , b[N] , c[5009][5009] = {} , tree[2 * N]; void build(int i , int l , int r){ if(l == r){ tree[i] = a[l]; return; } ll m = (l + r) / 2; build(i * 2 , l , m); build(i * 2 + 1, m + 1 , r); tree[i] = max(tree[2 * i] , tree[2 * i + 1]); } ll get(int i , int l , int r, int x , int y){ if(l > y || r < x) return 0; if(l >= x && r <= y) return tree[i]; ll m = (l + r) / 2; return max(get(2 * i , l , m ,x , y) , get(2 * i + 1 , m + 1 , r,x , y)); } void solve(){ ll q , i , j , m ,n, z ,s = 0 , f , l , r , k , x , y , mn = 1e18 , mx = 0; cin>>n; for(i = 1; i <= n; i++) cin>>a[i]; build(1 , 1 , n); for(i = 1; i <= n; i++) for(j = i + 2; j <= n; j++) l = i + 1, r = i + (j - i) / 2 , c[i][j] = max(c[i][j - 1], get(1 , 1 , n , l , r) + a[i] + a[j]); for(i = n; i >= 1; i--) for(j = n; j >= 1; j--) dp[i][j] = max({c[i][j] ,dp[i + 1][j]}); cin>>q; while(q--){ cin>>l>>r; cout<<dp[l][r]<<"\n"; } } int main(){ /* TL; #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif */ int t = 1; //cin>>t; while(t--) { solve(); } } // Author : حسن
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 1236 KB | Output is correct |
3 | Correct | 1 ms | 1236 KB | Output is correct |
4 | Correct | 1 ms | 1204 KB | Output is correct |
5 | Correct | 1 ms | 1236 KB | Output is correct |
6 | Correct | 1 ms | 1236 KB | Output is correct |
7 | Correct | 1 ms | 1236 KB | Output is correct |
8 | Correct | 1 ms | 1236 KB | Output is correct |
9 | Correct | 1 ms | 1236 KB | Output is correct |
10 | Correct | 1 ms | 1204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 1236 KB | Output is correct |
3 | Correct | 1 ms | 1236 KB | Output is correct |
4 | Correct | 1 ms | 1204 KB | Output is correct |
5 | Correct | 1 ms | 1236 KB | Output is correct |
6 | Correct | 1 ms | 1236 KB | Output is correct |
7 | Correct | 1 ms | 1236 KB | Output is correct |
8 | Correct | 1 ms | 1236 KB | Output is correct |
9 | Correct | 1 ms | 1236 KB | Output is correct |
10 | Correct | 1 ms | 1204 KB | Output is correct |
11 | Correct | 2538 ms | 323132 KB | Output is correct |
12 | Correct | 2515 ms | 323136 KB | Output is correct |
13 | Correct | 2500 ms | 323080 KB | Output is correct |
14 | Correct | 2540 ms | 323284 KB | Output is correct |
15 | Correct | 2543 ms | 323176 KB | Output is correct |
16 | Correct | 2527 ms | 322496 KB | Output is correct |
17 | Correct | 2595 ms | 322420 KB | Output is correct |
18 | Correct | 2526 ms | 322400 KB | Output is correct |
19 | Correct | 2666 ms | 323028 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4059 ms | 13344 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 1236 KB | Output is correct |
3 | Correct | 1 ms | 1236 KB | Output is correct |
4 | Correct | 1 ms | 1204 KB | Output is correct |
5 | Correct | 1 ms | 1236 KB | Output is correct |
6 | Correct | 1 ms | 1236 KB | Output is correct |
7 | Correct | 1 ms | 1236 KB | Output is correct |
8 | Correct | 1 ms | 1236 KB | Output is correct |
9 | Correct | 1 ms | 1236 KB | Output is correct |
10 | Correct | 1 ms | 1204 KB | Output is correct |
11 | Correct | 2538 ms | 323132 KB | Output is correct |
12 | Correct | 2515 ms | 323136 KB | Output is correct |
13 | Correct | 2500 ms | 323080 KB | Output is correct |
14 | Correct | 2540 ms | 323284 KB | Output is correct |
15 | Correct | 2543 ms | 323176 KB | Output is correct |
16 | Correct | 2527 ms | 322496 KB | Output is correct |
17 | Correct | 2595 ms | 322420 KB | Output is correct |
18 | Correct | 2526 ms | 322400 KB | Output is correct |
19 | Correct | 2666 ms | 323028 KB | Output is correct |
20 | Execution timed out | 4059 ms | 13344 KB | Time limit exceeded |
21 | Halted | 0 ms | 0 KB | - |