Submission #284714

#TimeUsernameProblemLanguageResultExecution timeMemory
284714ec1117Rice Hub (IOI11_ricehub)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef complex<ld> cd; typedef pair<int, int> pi; typedef pair<ll,ll> pl; typedef pair<ld,ld> pd; typedef vector<int> vi; typedef vector<ld> vd; typedef vector<ll> vl; typedef vector<pi> vpi; typedef vector<pl> vpl; typedef vector<cd> vcd; #define FOR(i, a, b) for (int i=a; i<(b); i++) #define F0R(i, a) for (int i=0; i<(a); i++) #define FORd(i,a,b) for (int i = (b)-1; i >= a; i--) #define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--) #define trav(a,x) for (auto& a : x) #define uid(a, b) uniform_int_distribution<int>(a, b)(rng) #define sz(x) (int)(x).size() #define mp make_pair #define pb push_back #define F first #define S second #define lb lower_bound #define ub upper_bound #define all(x) x.begin(), x.end() #define ins insert const int MOD = 1000000007; const char nl = '\n'; const int MX = 100001; //check the limits, dummy int besthub(int r,int l, int x[],ll b) { int lhub=0; int p=0; int rhub=0; ll rice=0;//riceused int mx=1; while(rhub<r-1 && rice+x[rhub+1]-x[p]<=b){ rhub++; rice+=x[rhub]-x[p]; } mx=max(mx, rhub-lhub+1); while(p<r-1 && rhub<r){ if(p==rhub){ rhub++; cout << "here"; rice-=x[p+1]-x[p]; } p++; cout << rice<<nl; rice+=-1LL*(x[p]-x[p-1])*((rhub-p)-(p-lhub-1)); cout << rice <<lhub << p << rhub<< nl; while(rice>b){//more hubs to the left than right rice-=x[p]-x[lhub];//remove lhub lhub++; } while(rhub<r-1 && p<r-1 && rice-(x[p]-x[lhub])+(x[rhub+1]-x[p])<=b){//do i add rhub+1? rice-=x[p]-x[lhub]; lhub++; while(rhub<r-1 && rice+x[rhub+1]-x[p]<=b){ rhub++; rice+=x[rhub]-x[p]; } if(lhub>p)break; } while(lhub!=0 && rice+(x[p]-x[lhub-1])<=b){ lhub--; rice+=x[p]-x[lhub]; } cout << rice << lhub << p << rhub<< nl; mx=max(mx,rhub-lhub+1); } return mx; } // int main(){ int r=3; int l=10; int x[]={0,2,3}; ll b=3; cout << besthub(r,l,x,b); return 0; } //int r=3; //int l=10; //int x[]={1,3,7}; //ll b=6; //cout << besthub(r,l,x,b); //return 0;

Compilation message (stderr)

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