版本比较
AT_agc065_a [AGC065A] Shuffle and mod K 题解
正文
增加 3 行删除 3 行
21 行未改动2223242526262728293015 行未改动464748495050515253542 行未改动575859606161626364652 行未改动21 行未改动
```cpp#include<bits/stdc++.h>#define ll long long#define N 500005 #define N 500005using namespace std;struct node{ll x,y;}p[N];ll n,k,a[N],i,j,b,ans1=LLONG_MIN,ans2=LLONG_MIN,tot,func,l=LLONG_MAX,r=LLONG_MIN,sam,pos;set<ll> op;15 行未改动 if(pos<sam){ if(op.size()) ans1=max(ans1,*op.begin()-p[i].x); else ans1=max(ans1,a[n]-p[i].x); } if(p[i].y>=sam-1) op.insert(p[i].x); if(p[i].y>=sam-1) op.insert(p[i].x); pos=max(pos,p[i].y); } sam=func+1,pos=0; op.clear();2 行未改动 if(pos<sam){ if(op.size()) ans2=max(ans2,*op.begin()-p[i].x); else ans2=max(ans2,a[n]-p[i].x); } if(p[i].y>=sam-1) op.insert(p[i].x); if(p[i].y>=sam-1) op.insert(p[i].x); pos=max(pos,p[i].y); } cout<<max(ans1+(n-func)*k,ans2+(n-func-1)*k)<<endl; return 0;2 行未改动