Submission #1098757

# Submission time Handle Problem Language Result Execution time Memory
1098757 2024-10-09T20:52:16 Z vjudge1 Sličice (COCI19_slicice) C++17
90 / 90
33 ms 528 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    vector<int> p,b;
    for(int n1=n;n1>0;n1--)
    {
        int x;
        cin>>x;
        p.push_back(x);
    }
    for(int n1=m+1;n1>0;n1--)
    {
        int x;
        cin>>x;
        b.push_back(x);
    }
    int res[501];
    memset(res,-1,sizeof(res));
    res[0]=0;
    int ress=0;
    for(int i=0;i<p.size();i++)
    {

        int br=p[i];
        int temp[501]={};
        for(int i1=0;i1<=500;i1++)
            temp[i1]=res[i1];
        for(int j=0;br<b.size();br++,j++)
        {

            for(int kk=0;kk<=k-j;kk++)
            {

                if(res[kk]==-1)
                break;

                if(temp[kk+j]==-1)
                {
                    temp[kk+j]=res[kk]+b[br];
                }

                temp[kk+j]=max(temp[kk+j],res[kk]+b[br]);
            }
        }
        for(int i1=0;i1<=500;i1++)
        {
            res[i1]=temp[i1];
            ress=max(ress,res[i1]);
        }
    }
    cout<<ress;
    return 0;
}

Compilation message

slicice.cpp: In function 'int main()':
slicice.cpp:26:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i=0;i<p.size();i++)
      |                 ~^~~~~~~~~
slicice.cpp:33:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for(int j=0;br<b.size();br++,j++)
      |                     ~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 528 KB Output is correct
3 Correct 28 ms 444 KB Output is correct
4 Correct 32 ms 348 KB Output is correct
5 Correct 32 ms 344 KB Output is correct
6 Correct 29 ms 344 KB Output is correct
7 Correct 31 ms 344 KB Output is correct
8 Correct 30 ms 448 KB Output is correct
9 Correct 29 ms 348 KB Output is correct
10 Correct 33 ms 348 KB Output is correct