Submission #401085

# Submission time Handle Problem Language Result Execution time Memory
401085 2021-05-09T10:37:28 Z EJOI2019Andrew Jelly Flavours (IOI20_jelly) C++14
10 / 100
2 ms 460 KB
#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

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 time Memory Grader output
1 Incorrect 1 ms 204 KB 1st lines differ - on the 1st token, expected: '8', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB 1st lines differ - on the 1st token, expected: '8', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB 1st lines differ - on the 1st token, expected: '689', found: '58'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 324 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 276 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 304 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 320 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 2 ms 304 KB Output is correct
26 Correct 1 ms 312 KB Output is correct
27 Correct 2 ms 332 KB Output is correct
28 Correct 2 ms 312 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 1 ms 304 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 2 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 1 ms 204 KB Output is correct
53 Correct 2 ms 308 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 1 ms 332 KB Output is correct
56 Correct 1 ms 332 KB Output is correct
57 Correct 1 ms 332 KB Output is correct
58 Correct 1 ms 332 KB Output is correct
59 Correct 1 ms 336 KB Output is correct
60 Correct 1 ms 308 KB Output is correct
61 Correct 1 ms 332 KB Output is correct
62 Correct 1 ms 312 KB Output is correct
63 Correct 1 ms 332 KB Output is correct
64 Correct 1 ms 332 KB Output is correct
65 Correct 1 ms 304 KB Output is correct
66 Correct 1 ms 332 KB Output is correct
67 Correct 1 ms 332 KB Output is correct
68 Correct 1 ms 332 KB Output is correct
69 Correct 1 ms 332 KB Output is correct
70 Correct 1 ms 316 KB Output is correct
71 Correct 1 ms 332 KB Output is correct
72 Correct 1 ms 332 KB Output is correct
73 Correct 1 ms 332 KB Output is correct
74 Correct 1 ms 304 KB Output is correct
75 Correct 1 ms 460 KB Output is correct
76 Correct 1 ms 332 KB Output is correct
77 Correct 1 ms 332 KB Output is correct
78 Correct 1 ms 332 KB Output is correct
79 Correct 1 ms 344 KB Output is correct
80 Correct 1 ms 332 KB Output is correct
81 Correct 1 ms 312 KB Output is correct
82 Correct 1 ms 332 KB Output is correct
83 Correct 1 ms 332 KB Output is correct
84 Correct 1 ms 332 KB Output is correct
85 Correct 1 ms 308 KB Output is correct
86 Correct 2 ms 332 KB Output is correct
87 Correct 1 ms 332 KB Output is correct
88 Correct 1 ms 332 KB Output is correct
89 Correct 1 ms 336 KB Output is correct
90 Correct 1 ms 332 KB Output is correct
91 Correct 1 ms 312 KB Output is correct
92 Correct 1 ms 300 KB Output is correct
93 Correct 1 ms 332 KB Output is correct
94 Correct 1 ms 332 KB Output is correct
95 Correct 1 ms 332 KB Output is correct
96 Correct 1 ms 332 KB Output is correct
97 Correct 1 ms 332 KB Output is correct
98 Correct 1 ms 332 KB Output is correct
99 Correct 1 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Incorrect 2 ms 332 KB 1st lines differ - on the 1st token, expected: '94', found: '93'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB 1st lines differ - on the 1st token, expected: '8', found: '2'
2 Halted 0 ms 0 KB -