답안 #1003381

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1003381 2024-06-20T09:30:29 Z vjudge1 쌀 창고 (IOI11_ricehub) C++17
0 / 100
1000 ms 2008 KB
#include<bits/stdc++.h>
#include "ricehub.h"
#define ll long long
#define ld long double
#define vl vector<ll>
#define vi vector<int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define f first
#define s second
#define pb push_back
#define p_b pop_back
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
    ll n = R, i;
    ll h[n+5], pref[n+5];
    pref[0] = 0;
    for(i = 1; i <= n; i++)
        h[i] = X[i-1];
    h[0] = X[0];
    for(i = 1; i <= n; i++)
        pref[i] = pref[i-1] + h[i];
    ll res = 0;
    for(i = 1; i <= n; i++)
    {
        vector<pll>vect;
        ll minn = LLONG_MAX, maxx = LLONG_MIN;
        for(ll j = 1; j <= n; j++)
            vect.pb({abs(h[i] - h[j]), j});
        ll sum = 0;
        //cout << "i: " << i << "\n";
        for(ll j = 0; j < vect.size(); j++)
        {
            //cout << vect[j].f << ' ' << vect[j].s << "\n";
            if(sum + vect[j].f <= B)
            {
                sum += vect[j].f;
                minn = min(minn, vect[j].s);
                maxx = max(maxx, vect[j].s);
            }
        }
        res = max(res, maxx - minn + 1);
    }
    return res;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:35:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for(ll j = 0; j < vect.size(); j++)
      |                       ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 604 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1014 ms 2008 KB Time limit exceeded
2 Halted 0 ms 0 KB -