Submission #224666

# Submission time Handle Problem Language Result Execution time Memory
224666 2020-04-18T14:39:02 Z monus1042 Rice Hub (IOI11_ricehub) C++17
42 / 100
1000 ms 1280 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
#define ll long long

int besthub(int R, int L, int X[], long long B)	{
	int ans=0;
	long long cost=0;

	for (int i=0; i<R; i++){
		multiset<int> se;
		for (int j=0; j<R; j++)
			se.insert(X[j]);
		se.insert(X[i]);
		cost=0;
		int pans=0;
		while(1){
			auto ff=se.find(X[i]), rb=se.begin(); rb--;
			auto fr=ff, fl=ff; fr++, fl--;
			if (fr==se.end() && fl==rb) break;
			else if (fr==se.end()){
				ll t2=X[i] - *fl;
				if (cost + t2 <= B){
					cost+=t2;
					pans++;
					se.erase(fl);
				}else break;
			}
			else if (fl==rb){
				ll t1=*fr - X[i];
				if (cost + t1 <= B){
					cost+=t1;
					pans++;
					se.erase(fr);
				}else break;
			}else{
				ll t1=*fr - X[i],t2=X[i] - *fl;
				if (t1<t2){
					if (cost + t1 <= B){
						cost+=t1;
						pans++;
						se.erase(fr);
					}else break;
				}else{
					if (cost + t2 <= B){
						cost+=t2;
						pans++;
						se.erase(fl);
					}else break;
				}
			}
		}
		ans=max(ans, pans);
	}

	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 6 ms 256 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 5 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 5 ms 256 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Correct 6 ms 256 KB Output is correct
16 Correct 6 ms 256 KB Output is correct
17 Correct 5 ms 256 KB Output is correct
18 Correct 5 ms 256 KB Output is correct
19 Correct 6 ms 256 KB Output is correct
20 Correct 6 ms 256 KB Output is correct
21 Correct 31 ms 384 KB Output is correct
22 Correct 26 ms 384 KB Output is correct
23 Correct 36 ms 384 KB Output is correct
24 Correct 36 ms 384 KB Output is correct
25 Correct 36 ms 384 KB Output is correct
26 Correct 37 ms 384 KB Output is correct
27 Correct 30 ms 384 KB Output is correct
28 Correct 32 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 384 KB Output is correct
2 Correct 7 ms 384 KB Output is correct
3 Correct 126 ms 408 KB Output is correct
4 Correct 115 ms 384 KB Output is correct
5 Correct 26 ms 384 KB Output is correct
6 Correct 27 ms 384 KB Output is correct
7 Correct 93 ms 384 KB Output is correct
8 Correct 95 ms 384 KB Output is correct
9 Correct 27 ms 384 KB Output is correct
10 Correct 27 ms 384 KB Output is correct
11 Correct 64 ms 384 KB Output is correct
12 Correct 66 ms 504 KB Output is correct
13 Correct 158 ms 384 KB Output is correct
14 Correct 143 ms 412 KB Output is correct
15 Correct 31 ms 384 KB Output is correct
16 Correct 32 ms 396 KB Output is correct
17 Correct 101 ms 384 KB Output is correct
18 Correct 93 ms 384 KB Output is correct
19 Correct 152 ms 504 KB Output is correct
20 Correct 147 ms 412 KB Output is correct
21 Execution timed out 1091 ms 512 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 1280 KB Time limit exceeded
2 Halted 0 ms 0 KB -