Submission #204661

#TimeUsernameProblemLanguageResultExecution timeMemory
204661tduong0806Triple Jump (JOI19_jumps)C++14
0 / 100
49 ms3704 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; int hmt() {int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';if(n) x=-x;return x;} #define in hmt() #define ins ({string x;char c=getchar();for(;c==' '||c=='\n';c=getchar());for(;c!=' '&&c!='\n';c=getchar()) x+=c;x;}) #define forinc(i,a,b) for(int i=a,_b=b;i<=_b;++i) #define fordec(i,a,b) for(int i=a;i>=b;--i) #define forb(i,BS) for(int i=BS._Find_first();i< BS.size();i = BS._Find_next(i)) #define forv(a,b) for(auto &a:b) #define pb push_back #define pii pair<int,int> #define fi first #define se second #define all(a) a.begin(),a.end() #define reset(f,x) memset(f,x,sizeof(f)) #define bit(x,i) ((x>>(i-1))&1) #define onbit(x,i) (x|(1<<(i-1))) #define offbit(x,i) (x&~(1<<(i-1))) const int N=500010; int n,b[4]; pii a[N]; int main() { //freopen("JOI2019.inp","r",stdin); n=in; forinc(i,1,n) a[i]={in,i}; sort(a+1,a+n+1); reverse(a+1,a+n+1); int ans=0; forinc(i,1,min(n,50)) forinc(j,i+1,min(n,50)) forinc(k,j+1,min(n,50)) { b[1]=a[i].se,b[2]=a[j].se,b[3]=a[k].se; sort(b+1,b+4); if(b[2]-b[1]<=b[3]-b[2]) ans=max(ans,a[i].fi+a[j].fi+a[k].fi); } cout<<ans<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...