# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
170562 | mdn2002 | Unija (COCI17_unija) | C++14 | 1085 ms | 33180 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const long long mod=998244353;
multiset<int>ms;
int n,k;
map<int,int>a;
int v[1000006];
vector<int>b;
int main()
{
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
//freopen("lemonade.in","r",stdin);
//freopen("lemonade.out","w",stdout);
scanf("%d",&n);
for(int i=0;i<n;i++)
{
int x,y;
scanf("%d",&x);
scanf("%d",&y);
x/=2;
y/=2;
if(a[y+1]==0)
{
a[y+1]=++k;
b.push_back(y+1);
}
if(v[a[y+1]]==0)
{
v[a[y+1]]=x;
continue;
}
if(v[a[y+1]]<x)v[a[y+1]]=x;
}
for(int i=0;i<b.size();i++)ms.insert(v[a[b[i]]]);
sort(b.begin(),b.end());
long long ans=0;
for(int i=0;i<b.size();i++)
{
int z=b[i],z1;
if(i>0)z1=b[i-1];
else z1=1;
ans+=*--ms.end()*(z-z1);
if(v[a[z]]!=0)
{
int x=v[a[z]];
ms.erase(ms.lower_bound(x));
}
if(ms.size()==0)break;
}
cout<<ans*4;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |