#include "ricehub.h"
#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
#define MAX_R 1000000
using namespace std;
typedef long long ll;
static int R, L;
static long long B;
static int X[MAX_R];
static int solution;
inline
void my_assert(int e) {if (!e) abort();}
static void read_input()
{
int i;
my_assert(3==scanf("%d %d %lld",&R,&L,&B));
for(i=0; i<R; i++)
my_assert(1==scanf("%d",&X[i]));
my_assert(1==scanf("%d",&solution));
}
int besthub(int R, int L, int X[], long long B){
ll maxrice=0;ll maxcost=0;
for(int i=1;i<=L;i++){
vector<ll> v;
for(int j=0;j<R;j++){
ll h=abs(X[j]-i);
v.push_back(h);
}
ll curr=0;
sort(v.begin(),v.end());
ll pos=B;
for(int j=0;j<v.size();j++){
if(pos-v[j]>=0){
curr++;
pos-=v[j];
}
else{
break;
}
}
if(maxrice<curr){
maxrice=curr;
}
}
return maxrice;
}/*
int main()
{
int ans;
read_input();
ans = besthub(R,L,X,B);
if(ans==solution)
printf("Correct.\n");
else
printf("Incorrect. Returned %d instead of %d.\n",ans,solution);
return 0;
}*/
Compilation message
ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:36:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<v.size();j++){
~^~~~~~~~~
ricehub.cpp:26:19: warning: unused variable 'maxcost' [-Wunused-variable]
ll maxrice=0;ll maxcost=0;
^~~~~~~
ricehub.cpp: At global scope:
ricehub.cpp:17:13: warning: 'void read_input()' defined but not used [-Wunused-function]
static void read_input()
^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 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 |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 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 |
256 KB |
Output is correct |
6 |
Correct |
6 ms |
256 KB |
Output is correct |
7 |
Correct |
6 ms |
384 KB |
Output is correct |
8 |
Correct |
6 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
304 KB |
Output is correct |
10 |
Correct |
5 ms |
256 KB |
Output is correct |
11 |
Correct |
4 ms |
256 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
4 ms |
384 KB |
Output is correct |
15 |
Correct |
6 ms |
256 KB |
Output is correct |
16 |
Correct |
7 ms |
256 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
4 ms |
256 KB |
Output is correct |
19 |
Correct |
7 ms |
256 KB |
Output is correct |
20 |
Correct |
7 ms |
256 KB |
Output is correct |
21 |
Correct |
11 ms |
384 KB |
Output is correct |
22 |
Correct |
12 ms |
384 KB |
Output is correct |
23 |
Correct |
121 ms |
376 KB |
Output is correct |
24 |
Correct |
119 ms |
384 KB |
Output is correct |
25 |
Correct |
111 ms |
384 KB |
Output is correct |
26 |
Correct |
114 ms |
256 KB |
Output is correct |
27 |
Correct |
98 ms |
376 KB |
Output is correct |
28 |
Correct |
104 ms |
408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
384 KB |
Output is correct |
2 |
Correct |
35 ms |
384 KB |
Output is correct |
3 |
Execution timed out |
1091 ms |
384 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1083 ms |
1220 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |