Submission #1003347

# Submission time Handle Problem Language Result Execution time Memory
1003347 2024-06-20T09:05:43 Z vjudge1 Rice Hub (IOI11_ricehub) C++17
68 / 100
1000 ms 1220 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pll pair<ll, ll>
/*ll p[5005];

pll binary1(ll b, ll e, ll num, ll money)
{
    ll l = b, r = e, ans = 0;
    while (l <= r){
        ll m = (l + r)/2;
        if (p[m] - p[b-1] - ((m-b+1)*num) <= money){
            l = m + 1;
            ans = money - (p[m] - p[b-1] - ((m-b+1)*num));
        }
        else {
            r = m - 1;
        }
    }
    return {ans, l-1};
}

pll binary2(ll b, ll e, ll num, ll money)
{
    ll l = b, r = e, ans = 0;
    while (l <= r){
        ll m = (l + r)/2;
        if ((e-m+1)*num - (p[e] - p[m-1]) <= money){
            r = m - 1;
            ans = money - (e-m+1)*num - (p[e] - p[m-1]);
        }
        else {
            l = m + 1;
        }
    }
    return {ans, r+1};
}*/

int besthub(int n, int l, int a[], long long b)
{
    /*for (ll i = 0; i<n; i++){
        p[i+1] = p[i] + a[i];
    }*/
    ll mx = 0;
    for (ll i = 0; i<n; i++){
        vector<ll>v;
        for (ll j = 0; j<i; j++){
            v.push_back(a[i] - a[j]);
        }
        for (ll j = i; j<n; j++){
            v.push_back(a[j] - a[i]);
        }
        sort(v.begin(), v.end());
        ll sum = 0, cnt = 0;
        for (ll j = 0; j<v.size(); j++){
            sum += v[j];
            cnt++;
            if (sum > b){
                cnt--;
                break;
            }
        }
        mx = max(mx, cnt);
    }
    return mx;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:57:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |         for (ll j = 0; j<v.size(); j++){
      |                        ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 2 ms 348 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 4 ms 348 KB Output is correct
24 Correct 4 ms 348 KB Output is correct
25 Correct 4 ms 348 KB Output is correct
26 Correct 4 ms 600 KB Output is correct
27 Correct 5 ms 348 KB Output is correct
28 Correct 4 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 14 ms 468 KB Output is correct
4 Correct 12 ms 348 KB Output is correct
5 Correct 2 ms 444 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 8 ms 348 KB Output is correct
8 Correct 8 ms 348 KB Output is correct
9 Correct 4 ms 348 KB Output is correct
10 Correct 4 ms 456 KB Output is correct
11 Correct 10 ms 464 KB Output is correct
12 Correct 10 ms 600 KB Output is correct
13 Correct 16 ms 464 KB Output is correct
14 Correct 16 ms 348 KB Output is correct
15 Correct 4 ms 456 KB Output is correct
16 Correct 4 ms 348 KB Output is correct
17 Correct 10 ms 452 KB Output is correct
18 Correct 10 ms 348 KB Output is correct
19 Correct 16 ms 476 KB Output is correct
20 Correct 16 ms 348 KB Output is correct
21 Correct 340 ms 348 KB Output is correct
22 Correct 350 ms 568 KB Output is correct
23 Correct 674 ms 600 KB Output is correct
24 Correct 633 ms 600 KB Output is correct
25 Correct 612 ms 600 KB Output is correct
26 Correct 647 ms 604 KB Output is correct
27 Correct 584 ms 604 KB Output is correct
28 Correct 510 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1047 ms 1220 KB Time limit exceeded
2 Halted 0 ms 0 KB -