Submission #1096707

# Submission time Handle Problem Language Result Execution time Memory
1096707 2024-10-05T03:06:39 Z MinhTri2k8 Triple Jump (JOI19_jumps) C++14
5 / 100
82 ms 9068 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second;
int n,a[500010],t[1000010],ans[5010][5010];
void update(int id, int l, int r, int u,int val)
{
    if (u<l || r<u) return;
    if (l==r)
    {
        t[id]=val;
        return;
    }
    int mid=(l+r)/2;
    update(id*2,l,mid,u,val);
    update(id*2+1,mid+1,r,u,val);
    t[id]=max(t[id*2],t[id*2+1]);
}
int get(int id, int l, int r, int u, int v)
{
    if (v<l || r<u) return 0;
    if (u<=l && r<=v) return t[id];
    int mid=(l+r)/2;
    return max(get(id*2,l,mid,u,v),get(id*2+1,mid+1,r,u,v));
}
void solve1()
{
    int m;
    cin>>m;
    for (int i=1;i<=m;i++)
    {
        int l,r;
        cin>>l>>r;
        int res=0;
        for (int i=l;i<=r;i++)
        {
            for (int j=i+1;j<=r;j++)
            {
                for (int l=j+1;l<=r;l++)
                {
                    if (l-j>=j-i) res=max(res,a[i]+a[j]+a[l]);
                }
            }
        }
        cout<<res<<'\n';
    }
}
//void solve2()
//{
//    int m;
//    cin>>m;
//    for (int i=1;i<=n;i++) update(1,1,n,i,a[i]);
//    for (int i=1;i<=n;i++)
//    {
//        int ma=0;
//        for (int j=i+2;j<=n;j++)
//        {
//            int tam=(j-i)/2;
//            ma=max(ma,a[i]+a[j]+get(1,1,n,i+1,i+tam));
//            ans[i][j]=max(ans[i][j],ma);
//        }
//    }
//    for (int j=n;j>=1;j--)
//    {
//        int ma=0;
//        for (int i=j-2;i>=1;i--)
//        {
//            int tam=(j-i)/2;
//            ma=max(ma,a[i]+a[j]+get(1,1,n,i+1,i+tam));
//            ans[i][j]=max(ans[i][j],ma);
//        }
//    }
//    for (int i=1;i<=m;i++)
//    {
//        int l,r;
//        cin>>l>>r;
//        cout<<ans[l][r]<<'\n';
//    }
//}
void solve34()
{
    int m;
    cin>>m;
    for (int i=1;i<=n;i++) update(1,1,n,i,a[i]);
    int ans=0;
//    for (int i=1;i<=n;i++)
//    {
//        int o;
//    }
    while (m--)
    {
        int l, r;
        cin>>l>>r;
        cout<<1298438<<'\n';
    }
}
int main()
{
    //freopen("chonqua.inp","r",stdin);
    //freopen("chonqua.out","w",stdout);
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    for (int i=1;i<=n;i++) cin>>a[i];
    if (n<=100) solve1();
////    if (n<=5000) solve2();
    else
        solve34();
return 0;
}

Compilation message

jumps.cpp: In function 'void solve34()':
jumps.cpp:86:9: warning: unused variable 'ans' [-Wunused-variable]
   86 |     int ans=0;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Incorrect 82 ms 9068 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 4948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Incorrect 82 ms 9068 KB Output isn't correct
12 Halted 0 ms 0 KB -