Submission #170535

# Submission time Handle Problem Language Result Execution time Memory
170535 2019-12-25T15:13:55 Z mdn2002 Unija (COCI17_unija) C++14
80 / 100
688 ms 65540 KB
#include<bits/stdc++.h>
using namespace std;
const long long mod=998244353;
multiset<int>ms;
int n,k,a[10000007];
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;
        ms.insert(x);
        v[a[y+1]].push_back(x);
    }
    long long ans=0;
    for(int i=1;i<=10000000;i++)
    {
        for(int j=0;j<v[a[i]].size();j++)
        {
            ms.erase(ms.find(v[a[i]][j]));
        }
        if(ms.size()==0)break;
        ans+=*--ms.end();
    }
    cout<<ans*4;
}

Compilation message

unija.cpp: In function 'int main()':
unija.cpp:28:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=0;j<v[a[i]].size();j++)
                     ~^~~~~~~~~~~~~~~
# 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 28 ms 23800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 23928 KB Output is correct
2 Correct 27 ms 23928 KB Output is correct
3 Correct 27 ms 23872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 23928 KB Output is correct
2 Correct 28 ms 23924 KB Output is correct
3 Correct 29 ms 23928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 24184 KB Output is correct
2 Correct 26 ms 24184 KB Output is correct
3 Correct 31 ms 24184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 675 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 23800 KB Output is correct
2 Correct 23 ms 23880 KB Output is correct
3 Correct 27 ms 23800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 26204 KB Output is correct
2 Correct 56 ms 26104 KB Output is correct
3 Correct 47 ms 26104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 138 ms 31500 KB Output is correct
2 Correct 126 ms 31580 KB Output is correct
3 Correct 136 ms 31580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 485 ms 47212 KB Output is correct
2 Correct 477 ms 47064 KB Output is correct
3 Correct 472 ms 51064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 688 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -