Submission #370658

# Submission time Handle Problem Language Result Execution time Memory
370658 2021-02-24T12:17:08 Z TLP39 Sails (IOI07_sails) C++14
0 / 100
114 ms 10092 KB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long int n;
    scanf("%lld",&n);
    pair<long long int,long long int> kh[n];
    long long int k,h;
    for(long long int i=0;i<n;i++)
    {
        scanf("%lld %lld",&k,&h);
        kh[i]={k,h};
    }
    sort(kh,kh+n);
    map<long long int,long long int> change;
    long long int ma=0,mi=100001;
    auto it=change.begin();
    long long int ch,hol1;
    for(long long int i=0;i<n;i++)
    {
        k=kh[i].first;
        h=kh[i].second;
        if(k>ma && mi)
        {
            change[ma]=mi;
            mi=0;
        }
        ma=k;
        it=change.upper_bound(k-h);
        it--;
        if((*it).first==k-h)
        {
            (*it).second--;
            if((*it).second==0) change.erase(it);
            mi++;
        }
        else
        {
            ch=0;
            hol1=(*it).first;
            it++;
            if(it==change.end()) ch=1;
            if(ch)
            {
                change[h+hol1]=1;
                change[hol1]--;
                if(!change[hol1]) change.erase(hol1);
            }
            else
            {
                mi++;
                change[hol1+((*it).first)-k+h]=1;
                change[hol1]--;
                if(!change[hol1]) change.erase(hol1);
                change[(*it).first]--;
                if(!change[(*it).first]) change.erase(it);
            }
        }
    }
    long long int val=100001;
    long long int ans=0;
    for(long long int i=0;i<ma;i++)
    {
        val-=change[i];
        printf("X %lld\n",val);
        ans+=val*(val-1)/2;
    }
    printf("%lld",ans);
}

Compilation message

sails.cpp: In function 'int main()':
sails.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |     scanf("%lld",&n);
      |     ~~~~~^~~~~~~~~~~
sails.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |         scanf("%lld %lld",&k,&h);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 2540 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 3180 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 58 ms 5228 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 75 ms 9452 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 85 ms 9836 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 114 ms 10092 KB Output isn't correct
2 Halted 0 ms 0 KB -