Submission #170553

# Submission time Handle Problem Language Result Execution time Memory
170553 2019-12-25T15:38:07 Z mdn2002 Unija (COCI17_unija) C++14
80 / 100
1000 ms 65536 KB
#include<bits/stdc++.h>
using namespace std;
const long long mod=998244353;
multiset<int>ms;
int n,k;
map<int,int>a;
vector<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]].size()==0)
        {
            v[a[y+1]].push_back(x);
            ms.insert(x);
            continue;
        }
        if(*v[a[y+1]].begin()<x)
        {
            ms.erase(ms.find(*v[a[y+1]].begin()));
            ms.insert(x);
            v[a[y+1]].clear();
            v[a[y+1]].push_back(x);
        }
    }
    long long ans=0;
    for(int i=1;i<=10000004;i++)
    {
        if(v[a[i]].size())
        {
            int x=*v[a[i]].begin();
            ms.erase(ms.find(x));
        }
        if(ms.size()==0)break;
        ans+=*--ms.end();
    }
    cout<<ans*4;
}
# Verdict Execution time Memory Grader output
1 Correct 23 ms 23800 KB Output is correct
2 Correct 23 ms 23800 KB Output is correct
3 Correct 23 ms 23800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 23800 KB Output is correct
2 Correct 23 ms 23928 KB Output is correct
3 Correct 23 ms 23820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 23928 KB Output is correct
2 Correct 29 ms 23928 KB Output is correct
3 Correct 24 ms 23900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 24316 KB Output is correct
2 Correct 39 ms 24440 KB Output is correct
3 Correct 34 ms 24312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1020 ms 65536 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 24 ms 23800 KB Output is correct
2 Correct 23 ms 23800 KB Output is correct
3 Correct 23 ms 23800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 74 ms 26872 KB Output is correct
2 Correct 75 ms 26872 KB Output is correct
3 Correct 74 ms 26872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 238 ms 34168 KB Output is correct
2 Correct 243 ms 34040 KB Output is correct
3 Correct 238 ms 34044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 882 ms 57464 KB Output is correct
2 Correct 953 ms 57176 KB Output is correct
3 Correct 998 ms 57156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1060 ms 65536 KB Time limit exceeded
2 Halted 0 ms 0 KB -