Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
34496 方巾予 【S】T2 C++ 运行超时 0 1000 MS 1824 KB 857 2024-11-10 14:27:07

Tests(0/20):


#include<bits/stdc++.h> using namespace std; const int N=2e5+10; int n,q,ans; int op,l,r; struct node{ int val,ind; }a[N]; bool cmp1(node x,node y){ return x.val>y.val; } bool cmp2(node x,node y){ return x.ind<y.ind; } signed main(){ scanf("%d%d",&n,&q); for(int i=1;i<=n;i++){ scanf("%d",&a[i].val); a[i].ind=i; } while(q--){ scanf("%d%d%d",&op,&l,&r); if(op){ ans=0; sort(a+1+l,a+1+r,cmp1); for(int i=l;i<=r-2;i++){ if(a[i].val<a[i+1].val+a[i+2].val){ ans=a[i].val+a[i+1].val+a[i+2].val; break; } } printf("%d\n",ans); sort(a+1+l,a+1+r,cmp2); }else{ a[l].val=r; } } return 0; }


测评信息: