Submission #920893

#TimeUsernameProblemLanguageResultExecution timeMemory
920893cowwycowRice Hub (IOI11_ricehub)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define name "aaaaaa" void file(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } } long long n, c, k; long long a[100005] = {0}; long long pre[100005]; void solve (){ cin >> n >> c >> k; pre[0] = 0; for(long long i = 1; i <= n; i++){ cin >> a[i]; pre[i] += pre[i - 1] + a[i]; } long long ans = 0; for(long long i = 1; i <= n; i++){ long long l = i, r = n, mid; while(l < r){ mid = (l + r + 1) / 2; long long pos = (i + mid) / 2; long long cost = a[pos - 1] * (pos - i + 1) - (pre[pos] - pre[i - 1]) + (pre[mid] - pre[pos]) - (mid - pos) * a[pos - 1]; if(cost > k){ r = mid - 1; }else{ l = mid; } } ans = max(ans, l - i + 1); } cout << ans; } int main(){ file(); solve(); }

Compilation message (stderr)

ricehub.cpp: In function 'void file()':
ricehub.cpp:8:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |         freopen(name".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ricehub.cpp:9:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |         freopen(name".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccMHZDWG.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccF1yqpJ.o:ricehub.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccMHZDWG.o: in function `main':
grader.cpp:(.text.startup+0xae): undefined reference to `besthub(int, int, int*, long long)'
collect2: error: ld returned 1 exit status