Submission #289595

# Submission time Handle Problem Language Result Execution time Memory
289595 2020-09-02T18:48:43 Z Doxeno Rice Hub (IOI11_ricehub) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
using namespace std;
int N;
long long B;
void in(int &n) {
   n = 0;
   int c = getc_unlocked(stdin), m = 0;
   for (; c < '0' || c > '9'; c = getc_unlocked(stdin))
	   if (c == '-') m = 1;
   for (; c >= '0' && c <= '9'; c = getc_unlocked(stdin))
	   n = (n << 1) + (n << 3) + c - '0';
   if (m) n = -n;
}
void lin(long long &n) {
   n = 0;
   int c = getc_unlocked(stdin), m = 0;
   for (; c < '0' || c > '9'; c = getc_unlocked(stdin))
	   if (c == '-') m = 1;
   for (; c >= '0' && c <= '9'; c = getc_unlocked(stdin))
	   n = (n << 1) + (n << 3) + c - '0';
   if (m) n = -n;
}
void out(int n) {
   if (!n) putc_unlocked('0', stdout);
   int c[11], i = 0;
   if (n < 0) { putc_unlocked('-', stdout); n = -n; }
   for (; n; n /= 10, i++) c[i] = n % 10 + '0';
   for (i--; i >= 0; putc_unlocked(c[i], stdout), i--);
   putc_unlocked('\n', stdout);
}
int main(){
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	in(N); lin(B);
	long long risaie[N];
	for(int i = 0; i < N; i++)lin(risaie[i]);
	int left=0,right=0;
	long long spesa = 0;
	int m =1;
	while(right<N-1){
		if(spesa>B){
			spesa+=risaie[left]-risaie[(++left+right)/2];
		}else{
			right++;
			spesa+=risaie[right]-risaie[(left+right)/2];
		//	if(spesa<=B)m=max(,max
		}
		if(spesa<=B)m=max(m,right-left+1);
	}
	out(m);
	return 0;
}

Compilation message

ricehub.cpp: In function 'int main()':
ricehub.cpp:43:32: warning: operation on 'left' may be undefined [-Wsequence-point]
   43 |    spesa+=risaie[left]-risaie[(++left+right)/2];
      |                                ^~~~~~
ricehub.cpp:43:32: warning: operation on 'left' may be undefined [-Wsequence-point]
ricehub.cpp:33:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   33 |  freopen("input.txt","r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
ricehub.cpp:34:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   34 |  freopen("output.txt","w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/cc9cq8bV.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc9EK7pi.o:ricehub.cpp:(.text.startup+0x0): first defined here
/tmp/cc9cq8bV.o: In function `main':
grader.cpp:(.text.startup+0x9a): undefined reference to `besthub(int, int, int*, long long)'
collect2: error: ld returned 1 exit status