Submission #224591

# Submission time Handle Problem Language Result Execution time Memory
224591 2020-04-18T13:16:36 Z DanerZein Rice Hub (IOI11_ricehub) C++14
42 / 100
1000 ms 4828 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
long long ma;
int besthub(int R, int L, int X[], long long B){

    vector<long long> S;
    for(long long i=0;i<R;i++){

        for(long long j=i;j<R;j++){
            long long b=B;
            vector<long long>ps;
            for(long long k=i;k<=j;k++){
                ps.push_back(X[k]);
            }
            long long mi=i+j;
            mi/=2;
            mi=X[mi];
            /*long long mi=ps[0]+ps[ps.size()-1];
            mi/=2;*/
           /* printf("i:%d j:%d mi:%d\n",i,j,mi);
            for(int k=0;k<ps.size();k++){
                cout<<ps[k]<<" ";
            }xh
            cout<<endl;*/
            bool sw=0;
            for(long long k=0;k<ps.size();k++){
                long long c=abs(mi-ps[k]);
                b-=c;
                if(b<0){
                    sw=1;
                    break;
                }
                /*if(b-c<0){
                    sw=1;
                    break;
                }
                else{

                    b-=c;
                }*/
            }
            /*if(ps.size()==245){
                for(int k=0;k<ps.size();k++){
                    cout<<ps[k]<<" ";
                }
                cout<<endl;
                cout<<b<<endl;
                if(b>=0){
                    cout<<"YES"<<endl;
                }
            }*/
            if(sw==0 or b>=0){
              /*  for(int k=0;k<ps.size();k++){
                    cout<<ps[k]<<" ";
                }*/
                //cout<<ps.size()<<endl;
                //cout<<i<<" "<<j<<endl;
                S.push_back(ps.size());
            }
        }
    }
    ma=-1;
    for(long long i=0;i<S.size();i++){
        ma=max(ma,S[i]);
    }
    //cout<<ma<<endl;
return ma;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:27:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(long long k=0;k<ps.size();k++){
                               ~^~~~~~~~~~
ricehub.cpp:64:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(long long i=0;i<S.size();i++){
                       ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 7 ms 384 KB Output is correct
8 Correct 7 ms 384 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 9 ms 384 KB Output is correct
16 Correct 7 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 7 ms 384 KB Output is correct
20 Correct 8 ms 384 KB Output is correct
21 Correct 178 ms 760 KB Output is correct
22 Correct 176 ms 728 KB Output is correct
23 Correct 189 ms 1520 KB Output is correct
24 Correct 191 ms 1516 KB Output is correct
25 Correct 190 ms 1520 KB Output is correct
26 Correct 190 ms 1520 KB Output is correct
27 Correct 184 ms 1532 KB Output is correct
28 Correct 181 ms 1468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 384 KB Output is correct
2 Correct 16 ms 384 KB Output is correct
3 Correct 925 ms 4828 KB Output is correct
4 Correct 923 ms 4560 KB Output is correct
5 Correct 176 ms 632 KB Output is correct
6 Correct 174 ms 632 KB Output is correct
7 Execution timed out 1045 ms 1540 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1094 ms 984 KB Time limit exceeded
2 Halted 0 ms 0 KB -