답안 #418285

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
418285 2021-06-05T09:15:03 Z Maqsut_03 쌀 창고 (IOI11_ricehub) C++14
68 / 100
1000 ms 652 KB
#include "ricehub.h"
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int M = 1e9 + 7;

int besthub(int R, int L, int X[], long long B)
{
	ll ans = 0, m;
	for (int i=0; i<R; i++)
	{
		ll sum = 1, b = B, j = i;
		ll l = i - 1, r = i + 1;
		while (1)
		{
			if (r < R && l >= 0)
			{
     			if (X[i] - X[l] <= X[r] - X[i]) m = X[i] - X[l], l--;
				else m = X[r] - X[i], r++;
			}
			else if (r < R) m = X[r] - X[i], r++;
			else if (l >= 0) m = X[i] - X[l], l--;
			else break;
			if (m > b) break;
			else sum++, b -= m;
		}
		ans = max(ans, sum);
	}
    return ans;
} 

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:12:22: warning: unused variable 'j' [-Wunused-variable]
   12 |   ll sum = 1, b = B, j = i;
      |                      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 2 ms 300 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
14 Correct 2 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 3 ms 204 KB Output is correct
18 Correct 3 ms 204 KB Output is correct
19 Correct 4 ms 204 KB Output is correct
20 Correct 4 ms 204 KB Output is correct
21 Correct 3 ms 316 KB Output is correct
22 Correct 3 ms 332 KB Output is correct
23 Correct 40 ms 332 KB Output is correct
24 Correct 38 ms 332 KB Output is correct
25 Correct 96 ms 340 KB Output is correct
26 Correct 91 ms 312 KB Output is correct
27 Correct 24 ms 360 KB Output is correct
28 Correct 23 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 332 KB Output is correct
2 Correct 5 ms 332 KB Output is correct
3 Execution timed out 1078 ms 652 KB Time limit exceeded
4 Halted 0 ms 0 KB -