답안 #871714

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
871714 2023-11-11T11:13:58 Z Nonoze 메기 농장 (IOI22_fish) C++17
컴파일 오류
0 ms 0 KB
#include "fish.h"
#include "grader.cpp"

#include <bits/stdc++.h>
using namespace std;



long long max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w) {
	#define int long long
	bool tacha=true, tachb=true, tachc=true;
	for (int i = 0; i < m; ++i)
	{
		if (x[i]%2) tacha=false;
		if (x[i]>1) tachb=false;
		if (y[i]) tachc=false;
	}
	if (tacha)
	{
		int ans=0;
		for (int i = 0; i < m; ++i) ans+=w[i];
		return ans;
	}
	if (tachb)
	{
		vector<vector<int>> farm(2, vector<int> (n, 0));
		for (int i=0; i<m; i++) {
			farm[x[i]][y[i]]=w[i];
		}
		vector<int> suml, sumr;
		suml.push_back(farm[0][0]);
		sumr.push_back(farm[1][0]);
		for (int i=1; i<n; i++) {
			suml.push_back(suml.back()+farm[0][i]);
			sumr.push_back(sumr.back()+farm[1][i]);
		}
		if (n==2) return max(suml.back(), sumr.back());
		int ans=sumr.back();
		for (int i=0; i<n; i++) {
			ans=max(ans, suml[i]+sumr.back()-sumr[i]);
		}
		return ans;
	}
	#undef int
	return 0;
}

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:11:31: warning: variable 'tachc' set but not used [-Wunused-but-set-variable]
   11 |  bool tacha=true, tachb=true, tachc=true;
      |                               ^~~~~
/usr/bin/ld: /tmp/cc3deGNP.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccuQa7dP.o:fish.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status