답안 #460477

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
460477 2021-08-09T07:11:45 Z fuad27 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
0 ms 0 KB
#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
int besthub(int r, int l, int x[], long long b) {
	int MAX = 0;
	for(int i = 1;i<r;i++) {
		int c = 0;
		long long cost = 0;
		int p1 = 0, p2 = MAX-1
		while(p1 < r and p2 <= r) {
			if(cost <= b) {
				c = max(p2 - p1, c);
				p2++;
				if(p2 <= r)
					cost+=abs(x[p2-1] - x[i]);
			}
			else {
				cost-=abs(x[p1]-x[i]);
				p1++;
			}
		}
		MAX = max(c, MAX);
	}
	return MAX;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:10:3: error: expected ',' or ';' before 'while'
   10 |   while(p1 < r and p2 <= r) {
      |   ^~~~~
ricehub.cpp:8:13: warning: unused variable 'cost' [-Wunused-variable]
    8 |   long long cost = 0;
      |             ^~~~
ricehub.cpp:9:7: warning: unused variable 'p1' [-Wunused-variable]
    9 |   int p1 = 0, p2 = MAX-1
      |       ^~
ricehub.cpp:9:15: warning: unused variable 'p2' [-Wunused-variable]
    9 |   int p1 = 0, p2 = MAX-1
      |               ^~