Submission #335883

#TimeUsernameProblemLanguageResultExecution timeMemory
335883sumit_kk10Rice Hub (IOI11_ricehub)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL) #define ll long long int #define ld long double using namespace std; const int N = 1e6 + 5; const int MOD = 1e9 + 7; long long int besthub(int n, int l, int a[], long long int b){ long long int pre_sum[n] = {0}, suf_sum[n] = {0}, ans = 1; pre_sum[0] = a[0]; suf_sum[n - 1] = a[n - 1]; for(int i = 1; i < n; ++i) pre_sum[i] = pre_sum[i - 1] + a[i]; for(int i = n - 2; i >= 0; --i) suf_sum[i] = suf_sum[i + 1] + a[i]; for(int left = 0; left < n; ++left){ int low = left, high = n - 1; while(low <= high){ int right = (low + high) / 2; long long int middle = (left + right) / 2; long long int val = pre_sum[right] - pre_sum[middle] + suf_sum[left] - suf_sum[middle]; val -= (a[middle] * (right - left)); // cout << left << ' ' << right << ' ' << middle << ' ' << val << '\n'; if(val <= b){ ans = max(ans, (long long int) right - left + 1); low = right + 1; } else high = right - 1; } } return ans; } int main(){ int n, l; long long int b; cin >> n >> l >> b; int a[n]; for(int i = 0; i < n; ++i) cin >> a[i]; cout << besthub(n, l, a, b) << '\n'; }

Compilation message (stderr)

/tmp/ccWViIj9.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccWNjiJK.o:ricehub.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status