Submission #51024

# Submission time Handle Problem Language Result Execution time Memory
51024 2018-06-15T16:00:08 Z Mercenary Rice Hub (IOI11_ricehub) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

#define Rep(i,n)        for(int i = 0; i < (n); ++i)
#define Repd(i,n)       for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b)      for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b)     for(int i = (a); i >= (b); --i)
#define ALL(a)          (a).begin(), (a).end()
#define pb	push_back
#define NAME            "TEST"
#define FAST            ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define READ            freopen(NAME".INP","r",stdin);
#define WRITE           freopen(NAME".OUT","w",stdout);
#define gc 		getchar
#define pc		putchar
#define watch(x) 	cout << (#x) << " is " << (x) << '\n'

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef float fl;
typedef double db;
const int inf = 1e6;
const int Linf = 1e9;
const ll LLinf = (ll)1e18;
const int maxn = 1e6;


template<typename T = int> inline T read() {
	T val = 0, sign = 1; char ch;
	for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar())
		if (ch == '-') sign = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar())
		val = val * 10 + ch - '0';
	return sign * val;
}
int n , m , l;
ll a[maxn] , k , x[maxn];
bool chk(int p){
    for(int i = p ; i <= n ; ++i){
        int j = i - p + 1;
        int mid = (i + j) >> 1;
        ll c = a[i] - a[j] - (ll)(i - mid + 1) * (ll)x[mid] + (mid - j + 1) *(ll) x[mid];
        if(c <= k)return true;
    }
    return false;
}
int bs()
{
    int l = 0;
    int h = n;
    while(l <= h){
        int mid = (l + h) / 2;
        if(chk(mid))l = mid + 1;
        else h = mid - 1;
    }
    return l;
}
int main()
{
    FAST;
    cin >> n >> l >> k;
    a[0] = 0;
    For(i,1,n){
        cin >> x[i];
        a[i] = a[i-1] + x[i];
    }
    cout << bs();
}

Compilation message

/tmp/cc5KlPmu.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccIKtcS2.o:ricehub.cpp:(.text.startup+0x0): first defined here
/tmp/cc5KlPmu.o: In function `main':
grader.cpp:(.text.startup+0x92): undefined reference to `besthub(int, int, int*, long long)'
collect2: error: ld returned 1 exit status