Submission #115245

# Submission time Handle Problem Language Result Execution time Memory
115245 2019-06-06T09:47:43 Z oolimry Rice Hub (IOI11_ricehub) C++14
17 / 100
26 ms 3976 KB
#include "ricehub.h"
#include <bits/stdc++.h>

using namespace std;
int besthub(int R, int L, int X[], long long B)
{
    vector<int> untaken;
    for(int i = 0;i < R;i++){
        untaken.push_back(X[i]);
    }
    untaken.push_back(4 * L);
    sort(untaken.begin(),untaken.end());
    reverse(untaken.begin(),untaken.end());
    deque<int> left, right; ///front-closest, back-furthest
    long long acc = 0;
    int ans = 0;
    for(int i = 1;i <= L;i++){
        bool stop = false;
        while(!right.empty() && right.front() == i-1){
            right.pop_front();
            left.push_front(i-1);
        }
        acc -= right.size();
        acc += left.size();

        while(true){
            if(acc > B){
                if(right.empty()){
                    acc -= abs(left.back() - i);
                    left.pop_back();
                }
                else if(left.empty()){
                    acc -= abs(right.back() - i);
                    untaken.push_back(right.back());
                    right.pop_back();
                    stop = true;
                }
                else{
                    if(abs(right.back() - i) > abs(left.back() - i)){
                        acc -= abs(right.back() - i);
                        untaken.push_back(right.back());
                        right.pop_back();
                        stop = true;
                    }
                    else{
                        acc -= abs(left.back() - i);
                        left.pop_back();
                    }
                }
            }
            else{
                if(stop) break;
                ans = max(ans, (int)(left.size() + right.size()));
                acc += abs(untaken.back() - i);
                right.push_back(untaken.back());
                untaken.pop_back();
            }
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Incorrect 2 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Incorrect 16 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 768 KB Output is correct
2 Correct 6 ms 768 KB Output is correct
3 Runtime error 26 ms 3976 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -