Submission #170560

# Submission time Handle Problem Language Result Execution time Memory
170560 2019-12-25T15:49:32 Z mdn2002 Unija (COCI17_unija) C++14
80 / 100
1000 ms 44532 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];
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);
    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;
            b.push_back(y+1);
        }
        if(v[a[y+1]]==0)
        {
            v[a[y+1]]=x;
            ms.insert(x);
            continue;
        }
        if(v[a[y+1]]<x)
        {
            ms.erase(ms.lower_bound(v[a[y+1]]));
            ms.insert(x);
            v[a[y+1]]=x;
        }
    }
    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

unija.cpp: In function 'int main()':
unija.cpp:43:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<b.size();i++)
                 ~^~~~~~~~~
# 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 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 3 ms 376 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 7 ms 760 KB Output is correct
2 Correct 8 ms 760 KB Output is correct
3 Correct 7 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1064 ms 43700 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 43 ms 2652 KB Output is correct
2 Correct 44 ms 2644 KB Output is correct
3 Correct 45 ms 2680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 178 ms 8080 KB Output is correct
2 Correct 229 ms 8124 KB Output is correct
3 Correct 233 ms 8048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 724 ms 23416 KB Output is correct
2 Correct 690 ms 23380 KB Output is correct
3 Correct 751 ms 23324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1080 ms 44532 KB Time limit exceeded
2 Halted 0 ms 0 KB -