답안 #170550

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
170550 2019-12-25T15:36:45 Z mdn2002 Unija (COCI17_unija) C++14
70 / 100
358 ms 65540 KB
#include<bits/stdc++.h>
using namespace std;
const long long mod=998244353;
multiset<int>ms;
int n,k;
map<int,int>a;
multiset<int>v[1000000];
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]].insert(x);
            ms.insert(x);
            continue;
        }
        if(*--v[a[y+1]].end()<x)
        {
            ms.erase(ms.find(*v[a[y+1]].begin()));
            ms.insert(x);
            v[a[y+1]].clear();
            v[a[y+1]].insert(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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 47344 KB Output is correct
2 Correct 43 ms 47224 KB Output is correct
3 Correct 45 ms 47404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 47384 KB Output is correct
2 Correct 44 ms 47384 KB Output is correct
3 Correct 45 ms 47352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 47476 KB Output is correct
2 Correct 46 ms 47416 KB Output is correct
3 Correct 45 ms 47412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 47864 KB Output is correct
2 Correct 52 ms 47864 KB Output is correct
3 Correct 51 ms 47944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 316 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 47344 KB Output is correct
2 Correct 53 ms 47284 KB Output is correct
3 Correct 53 ms 47324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 97 ms 51140 KB Output is correct
2 Correct 99 ms 51056 KB Output is correct
3 Correct 98 ms 51120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 302 ms 59892 KB Output is correct
2 Correct 282 ms 59928 KB Output is correct
3 Correct 283 ms 60160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 358 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 317 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -