제출 #400908

#제출 시각아이디문제언어결과실행 시간메모리
400908DivannyJelly Flavours (IOI20_jelly)C++14
컴파일 에러
0 ms0 KiB
#include "jelly.h"
#include <bits/stdc++.h>

using namespace std;

int find_maximum_unique(int x, int y, vector<int> a, vector<int> b) 
{
	int n = a.size();
	int cont = 0;
	while (x > 0 || y > 0)
	{
		if (min(*min_element(a.begin(), a.end()), *min_element(b.begin(), b.end())) == *min_element(a.begin(), a.end()))
		{
			int i = min_element(a.begin(), a.end()) - a.begin();
		}
		else
		{
			int i = min_element(b.begin(), b.end()) - b.begin();
		}
		if ((a[i] < b[i] && x - a[i] >= 0) || (y - b[i] < 0 && x - a[i] >= 0))
		{
			x -= a[i];
			a[i] = 10001;
			b[i] = 10001;
			cont++;
		}
		else if (y - b[i] >= 0)
		{
			y -= b[i];
			a[i] = 10001;
			b[i] = 10001;
			cont++;
		}
		else
		{
			break;
		}
	}
	return cont;
}

컴파일 시 표준 에러 (stderr) 메시지

jelly.cpp: In function 'int find_maximum_unique(int, int, std::vector<int>, std::vector<int>)':
jelly.cpp:14:8: warning: unused variable 'i' [-Wunused-variable]
   14 |    int i = min_element(a.begin(), a.end()) - a.begin();
      |        ^
jelly.cpp:18:8: warning: unused variable 'i' [-Wunused-variable]
   18 |    int i = min_element(b.begin(), b.end()) - b.begin();
      |        ^
jelly.cpp:20:10: error: 'i' was not declared in this scope
   20 |   if ((a[i] < b[i] && x - a[i] >= 0) || (y - b[i] < 0 && x - a[i] >= 0))
      |          ^
jelly.cpp:8:6: warning: unused variable 'n' [-Wunused-variable]
    8 |  int n = a.size();
      |      ^