Submission #1003345

# Submission time Handle Problem Language Result Execution time Memory
1003345 2024-06-20T09:05:24 Z hacizadal Rice Hub (IOI11_ricehub) C++17
68 / 100
1000 ms 1080 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 344 KB Output is correct
2 Correct 1 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 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 424 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 448 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 460 KB Output is correct
21 Correct 2 ms 456 KB Output is correct
22 Correct 2 ms 456 KB Output is correct
23 Correct 4 ms 344 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 348 KB Output is correct
27 Correct 4 ms 396 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 12 ms 476 KB Output is correct
4 Correct 12 ms 472 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 8 ms 348 KB Output is correct
8 Correct 8 ms 472 KB Output is correct
9 Correct 4 ms 348 KB Output is correct
10 Correct 4 ms 344 KB Output is correct
11 Correct 10 ms 348 KB Output is correct
12 Correct 10 ms 348 KB Output is correct
13 Correct 16 ms 456 KB Output is correct
14 Correct 16 ms 348 KB Output is correct
15 Correct 4 ms 348 KB Output is correct
16 Correct 4 ms 348 KB Output is correct
17 Correct 13 ms 604 KB Output is correct
18 Correct 10 ms 348 KB Output is correct
19 Correct 15 ms 472 KB Output is correct
20 Correct 16 ms 348 KB Output is correct
21 Correct 336 ms 580 KB Output is correct
22 Correct 357 ms 568 KB Output is correct
23 Correct 633 ms 348 KB Output is correct
24 Correct 670 ms 344 KB Output is correct
25 Correct 686 ms 604 KB Output is correct
26 Correct 669 ms 604 KB Output is correct
27 Correct 541 ms 604 KB Output is correct
28 Correct 591 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1036 ms 1080 KB Time limit exceeded
2 Halted 0 ms 0 KB -