Submission #597021

#TimeUsernameProblemLanguageResultExecution timeMemory
597021PiejanVDCHorses (IOI15_horses)C++17
Compilation error
0 ms0 KiB
#include "horses.h" #include <bits/stdc++.h> using namespace std; #define int long long vector<long long>x,y; long long mod = (long long)1e9+7; int init(int n, int X[], int Y[]) { for(int i = 0 ; i < n ; i++) x.push_back(X[i]), y.push_back(Y[i]); int last = -1; long long got = 1; long long ans = 0; long long curr = 0; long long prev = -1; while(last < n-1) { for(int i = last+1 ; i < n ; i++) { got *= x[i]; got %= mod; if((y[i] * (got-1))%mod > prev%mod) last = i, prev = y[i] * (got-1); prev %= mod; // + case where you sell all of them ans = max(ans, (curr + y[i] * got)%mod); ans %= mod; } curr += prev; curr %= mod; prev = -1; got = 1; } ans = max(ans, curr); return ans; } int updateX(int p, int val) { int n = (int)x.size(); x[p] = val; int last = -1; long long got = 1; long long ans = 0; long long curr = 0; long long prev = -1; while(last < n-1) { for(int i = last+1 ; i < n ; i++) { got *= x[i]; got %= mod; if((y[i] * (got-1))%mod > prev%mod) last = i, prev = y[i] * (got-1); prev %= mod; // + case where you sell all of them ans = max(ans, (curr + y[i] * got)%mod); ans %= mod; } curr += prev; curr %= mod; prev = -1; got = 1; } ans = max(ans, curr); return ans; } int updateY(int p, int val) { int n = (int)x.size(); y[p] = val; int last = -1; long long got = 1; long long ans = 0; long long curr = 0; long long prev = -1; while(last < n-1) { for(int i = last+1 ; i < n ; i++) { got *= x[i]; got %= mod; if((y[i] * (got-1))%mod > prev%mod) last = i, prev = y[i] * (got-1); prev %= mod; // + case where you sell all of them ans = max(ans, (curr + y[i] * got)%mod); ans %= mod; } curr += prev; curr %= mod; prev = -1; got = 1; } ans = max(ans, curr); return ans; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccIR5v2n.o: in function `main':
grader.c:(.text.startup+0xaa): undefined reference to `init(int, int*, int*)'
/usr/bin/ld: grader.c:(.text.startup+0x113): undefined reference to `updateX(int, int)'
/usr/bin/ld: grader.c:(.text.startup+0x16d): undefined reference to `updateY(int, int)'
collect2: error: ld returned 1 exit status