Submission #707812

#TimeUsernameProblemLanguageResultExecution timeMemory
707812victor_gaoCake 3 (JOI19_cake3)C++17
24 / 100
4058 ms9776 KiB
//#pragma GCC optimize("Ofast,unroll-loops,O3") //#pragma GCC optimize("avx,avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,fma,tune=native") #include<bits/stdc++.h> //#include<bits/extc++.h> //#pragma pack(1) #define fast ios::sync_with_stdio(0); cin.tie(0); #define int long long #define pii pair<int,int> #define x first #define y second using namespace std; //using namespace __gnu_pbds; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //typedef tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> order_multiset; //typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> order_set; int n,m; pii arr[200015]; bool cmp(pii a,pii b){ if (a.y!=b.y) return a.y<b.y; return a.x<b.x; } signed main(){ fast cin>>n>>m; for (int i=1;i<=n;i++) cin>>arr[i].x>>arr[i].y; sort(arr+1,arr+1+n,cmp); int ans=-1e18; for (int i=1;i<=n-m+1;i++){ multiset<int>st; int sum=0; for (int j=0;j<m;j++){ st.insert(arr[i+j].x); sum+=arr[i+j].x; } ans=max(ans,sum-2*(arr[i+m-1].y-arr[i].y)); for (int j=i+m;j<=n;j++){ sum+=arr[j].x; st.insert(arr[j].x); sum-=(*st.begin()); st.erase(st.begin()); ans=max(ans,sum-2*(arr[j].y-arr[i].y)); } } cout<<ans<<'\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...