답안 #400908

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
400908 2021-05-08T19:55:29 Z Divanny Jelly Flavours (IOI20_jelly) C++14
컴파일 오류
0 ms 0 KB
#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;
}

Compilation message

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();
      |      ^