Submission #1291847

#TimeUsernameProblemLanguageResultExecution timeMemory
1291847eyadoozRice Hub (IOI11_ricehub)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define pb push_back #define all(x) (x).begin(), (x).end() #define sz(x) (int) (x).size() #define endl '\n' int main() { cin.tie(0) -> sync_with_stdio(0); int n, l, b; cin >> n >> l >> b; int a[n]; for(auto& i : a) cin >> i; sort(a,a+n); int ans=0; for(int i = 0;i < n;i++) { int l=i-1, r=i+1, fb=b, cnt=1; while(l!=-1&&r!=-1) { if(l!=-1&&r!=n) { // if(i==2) cout << l << " " << a[i] << " " << a[r] << " " << fb << endl; if(min(abs(a[r]-a[i]), abs(a[l]-a[i]))>fb) break; if(abs(a[r]-a[i])<abs(a[l]-a[i])) r++, cnt++, fb-=abs(a[r-1]-a[i]); else l--, cnt++, fb-=abs(a[l-1]-a[i]); } else if(l!=-1) { if(abs(a[i]-a[l])>fb) break; l--, cnt++, fb-=abs(a[i]-a[l-1]); } else if(r!=n) { if(abs(a[i]-a[r])>fb) break; r++, cnt++, fb-=abs(a[i]-a[r-1]); } } ans=max(ans, cnt); } cout << ans; }

Compilation message (stderr)

/usr/bin/ld: /tmp/cc27LfOk.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccR07kRa.o:ricehub.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc27LfOk.o: in function `main':
grader.cpp:(.text.startup+0xaa): undefined reference to `besthub(int, int, int*, long long)'
collect2: error: ld returned 1 exit status