Submission #170555

# Submission time Handle Problem Language Result Execution time Memory
170555 2019-12-25T15:40:15 Z mdn2002 Unija (COCI17_unija) C++14
Compilation error
0 ms 0 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]].begin()<x)
        {
            ms.erase(ms.find(*v[a[y+1]].begin()));
            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;
}

Compilation message

unija.cpp: In function 'int main()':
unija.cpp:29:23: error: request for member 'begin' in 'v[a.std::map<int, int>::operator[]((y + 1))]', which is of non-class type 'int'
         if(*v[a[y+1]].begin()<x)
                       ^~~~~
unija.cpp:31:41: error: request for member 'begin' in 'v[a.std::map<int, int>::operator[]((y + 1))]', which is of non-class type 'int'
             ms.erase(ms.find(*v[a[y+1]].begin()));
                                         ^~~~~
unija.cpp:33:22: error: expected ';' before ']' token
             v[a[y+1]]]x;
                      ^