Submission #477726

# Submission time Handle Problem Language Result Execution time Memory
477726 2021-10-03T10:28:25 Z Zhora_004 Rice Hub (IOI11_ricehub) C++17
17 / 100
1000 ms 2124 KB
#include "ricehub.h"
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#include <numeric>
#include <functional>
#include <chrono>
#include <cassert>
#include <bitset>
using namespace std;

int besthub(int R, int L, int X[], long long B)
{
	multiset<int> tmp;
	for (int i = 0; i < R; i++) tmp.insert(X[i]);
	int mx = 0;
	for (int i = 1; i <= L; i++)
	{
		int ans = 0;
		multiset<int> ms = tmp;
		long long b = B;
		while (b)
		{
			auto it1 = ms.lower_bound(i);
			int num1 = -1, num2 = -1;
			if (it1 != ms.end()) num1 = *it1;
			if (it1 != ms.begin()) it1--, num2 = *it1;
			if (num1 == -1 && num2 == -1) continue;
			if (num1 == -1)
			{
				if (i - num2 <= b) b -= i - num2, ans++, ms.erase(ms.find(num2));
				else break;
			}
			else if (num2 == -1)
			{
				if (num1 - i <= b) b -= num1 - i, ans++, ms.erase(ms.find(num1));
				else break;
			}
			else
			{
				if (min(num1 - i, i - num2) <= b)
				{
					if (num1 - i <= i - num2) b -= num1 - i, ans++, ms.erase(ms.find(num1));
					else b -= i - num2, ans++, ms.erase(ms.find(num2));
				}
				else break;
			}
		}
		mx = max(mx, ans);
	}
	return mx;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 62 ms 204 KB Output is correct
2 Correct 62 ms 296 KB Output is correct
3 Execution timed out 1089 ms 332 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 2124 KB Time limit exceeded
2 Halted 0 ms 0 KB -