Submission #401085

#TimeUsernameProblemLanguageResultExecution timeMemory
401085EJOI2019AndrewJelly Flavours (IOI20_jelly)C++14
10 / 100
2 ms460 KiB
#include "jelly.h"
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
int find_maximum_unique(int x, int y, std::vector<int> a, std::vector<int> b) {
if(y==0)
    {
        int sm(0),c(0);
        sort(all(a));
        for(auto i:a)
            {
                ++c;
                sm+=i;
                if(sm>x)
                    return c-1;
            }
            return a.size();
    }
    if(x==0)
    {
        int sm(0),c(0);
        sort(all(b));
        for(auto i:b)
            {
                ++c;
                sm+=i;
                if(sm>y)
                    return c-1;
            }
            return b.size();
    }
    else
    {
        int c(0),f(0),h(0);
        for(auto i:b)
        {
            if(i==b[0])
                ++c;
            if(i==a[h])
                ++f;
            ++h;
        }
    if(c==b.size()&&f==a.size())
        {
            return max(min((int)a.size(),x/a[0])+min((int)a.size()-min((int)a.size(),x/a[0]),y/b[0]),min((int)a.size(),y/b[0])+min((int)a.size()-min((int)a.size(),y/b[0]),x/a[0]));
        }
        else if(c==b.size())
        {
        int s(0),s1(0),g(0);
        int c(0),sm(0);
        sort(all(a));
        for(auto i:a)
            {
                ++c;
                sm+=i;
                if(sm>x)
                    {
                        s=c-1;

                        g=1;
                        break;
                    }
            }

            if(g==0)
                s=a.size();

            s+=min((int)a.size()-s,y/b[0]);

             s1=min((int)a.size(),y/b[0]);

             int k(0),n(s1);
             c=0,sm=0;

             sort(all(a));
             for(auto l:a)
             {
                ++c;
                if(c-1==a.size()-s1)
                    break;
                sm+=l;
                if(sm>x)
                {
                    s1+=c-1;
                    k=1;
                    break;
                }
             }

             if(k==0)
             s1+=a.size()-n;
             return max(s,s1);
        }
        else if(f==a.size())
        {

               int sm(0), c(0),w(0);



                   int h(0),k(0);

                 map<int,int>v;
                sort(all(a));
                int    s(0);
                for(auto l:a)
            {
                ++c;
                sm+=l;
                if(sm>x)
                {
                    s=c-1;
                    k=1;
                    break;
                }
                 v[h]=1;
                 ++h;
             }
             if(k==0)
             {
                  for(int p=0; p<a.size(); ++p)
                      v[p]=1;
             }
               sort(all(b));
                 c=0;
                sm=0;


                h=0,k=0;

                int s1(0);
                for(auto l:b)
            {
                  if(!v[h])
                  {

                ++c;
                sm+=l;
                if(sm>y)
                {
                    s1=c-1;
                    k=1;
                    break;
                }


               }
                 ++h;

            }
             if(k==0)
             {
                if(v[0])
                 s1=0;
                else
                     s1=a.size();
             }

                  w=s+s1;


                        int c1=0,sm1(0);



                   int h1=0,k1=0;

                 map<int,int>v1;
                sort(all(b));
                s1=0;
                for(auto l:b)
            {
                ++c1;
                sm1+=l;
                if(sm1>x)
                {
                    s1=c1-1;
                    k1=1;
                    break;
                }
                 v1[h1]=1;
                 ++h1;
             }
             if(k1==0)
             {
                  for(int p=0; p<b.size(); ++p)
                      v1[p]=1;
             }
               sort(all(a));
                 c1=0;
                sm1=0;


                int h2=0;
                k1=0;

                int s2(0);
                for(auto l:a)
            {
                  if(!v1[h2])
                  {

                ++c1;
                sm1+=l;
                if(sm1>y)
                {
                    s2=c1-1;
                    k1=1;
                    break;
                }

                  }
                 ++h1;

            }
             if(k1==0)
             {
                if(v1[0])
                 s2=0;
                else
                     s2=a.size();
             }

                 return max(w,s1+s2);

        }

        else
            return rand()%a.size()+1;
    }
}

Compilation message (stderr)

jelly.cpp: In function 'int find_maximum_unique(int, int, std::vector<int>, std::vector<int>)':
jelly.cpp:43:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     if(c==b.size()&&f==a.size())
      |        ~^~~~~~~~~~
jelly.cpp:43:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     if(c==b.size()&&f==a.size())
      |                     ~^~~~~~~~~~
jelly.cpp:47:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         else if(c==b.size())
      |                 ~^~~~~~~~~~
jelly.cpp:79:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |                 if(c-1==a.size()-s1)
      |                    ~~~^~~~~~~~~~~~~
jelly.cpp:94:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   94 |         else if(f==a.size())
      |                 ~^~~~~~~~~~
jelly.cpp:121:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  121 |                   for(int p=0; p<a.size(); ++p)
      |                                ~^~~~~~~~~
jelly.cpp:186:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  186 |                   for(int p=0; p<b.size(); ++p)
      |                                ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...