Ant Counting Time Limit : 2000/1000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other) Total Submission(s) : 3 Accepted Submission(s) : 2 Problem Description Bessie was poking around the ant hill one day watching the ants march to and fro w…
#include<bits/stdc++.h>using namespace std;const long long N=1e5+5;const long long MOD=1e9+7;long long n,x,y,ans=0;long long cost[N];pair<long long,long long>a[N];multiset<pair<pair<long long,long long>,long long> >s;int main…
#define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;multiset<long long>mst;long long a[100007];int main(){ long long n; cin>>n; long long x; for(long long i=0;i<n;++i){ cin>>x; a[x]=i; } mst.insert(-1); mst.in…