답안 #874019

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
874019 2023-11-16T07:52:46 Z OSoverspike 친구 (IOI14_friend) C++17
컴파일 오류
0 ms 0 KB
#include "friend.h"

// Find out best sample
int findSample(int n,int confidence[],int host[],int protocol[]){
	int ans=0;
	if (protocol[1]=="MyFriendsAreYourFriends") {
        for (int a=0; a<=n; a++) {
            ans+=confidence[a];
        }
    } else {
        for (int a=0; a<=n; a++) {
            ans=max(ans, confidence[a]);
        }
    }
	return ans;
}

Compilation message

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:6:17: warning: comparison with string literal results in unspecified behavior [-Waddress]
    6 |  if (protocol[1]=="MyFriendsAreYourFriends") {
      |      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
friend.cpp:6:17: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
friend.cpp:12:17: error: 'max' was not declared in this scope
   12 |             ans=max(ans, confidence[a]);
      |                 ^~~