Submission #170557

# Submission time Handle Problem Language Result Execution time Memory
170557 2019-12-25T15:41:10 Z mdn2002 Unija (COCI17_unija) C++14
80 / 100
1000 ms 49580 KB
#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];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("lemonade.in","r",stdin);
    //freopen("lemonade.out","w",stdout);
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        x/=2;
        y/=2;
        if(a[y+1]==0)a[y+1]=++k;
        if(v[a[y+1]]==0)
        {
            v[a[y+1]]=x;
            ms.insert(x);
            continue;
        }
        if(v[a[y+1]]<x)
        {
            ms.erase(ms.find(v[a[y+1]]));
            ms.insert(x);
            v[a[y+1]]=x;
        }
    }
    long long ans=0;
    for(int i=1;i<=10000004;i++)
    {
        if(v[a[i]]!=0)
        {
            int x=v[a[i]];
            ms.erase(ms.find(x));
        }
        if(ms.size()==0)break;
        ans+=*--ms.end();
    }
    cout<<ans*4;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 404 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 732 KB Output is correct
2 Correct 8 ms 760 KB Output is correct
3 Correct 8 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 49580 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 2852 KB Output is correct
2 Correct 53 ms 2808 KB Output is correct
3 Correct 48 ms 2808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 197 ms 8568 KB Output is correct
2 Correct 214 ms 8400 KB Output is correct
3 Correct 195 ms 8440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 745 ms 24740 KB Output is correct
2 Correct 885 ms 24840 KB Output is correct
3 Correct 758 ms 24832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1071 ms 48624 KB Time limit exceeded
2 Halted 0 ms 0 KB -