답안 #38810

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
38810 2018-01-06T16:09:35 Z Waschbar Gap (APIO16_gap) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
 
const long long INF = 1e18;
 
long long findGap(int T, int N) {
 
	multiset < pair< long long,pair<long long,long long> > > st;
	long long mn, mx;
	MinMax(0ll,INF,&mn,&mx);
	st.insert({-(mx-mn),{mn,mx}});
	long long ans = 0;
 
    if(N == 2){
        return mx - mn;
    }
	
	if (T == 1){
		for (int i=1;i<(N+1)/2;i++){
			long long mmn, mmx;
			MinMax(mn+1,mx-1,&mmn,&mmx);
			ans = max(ans,mmn-mn);
			ans = max(ans,mx-mmx);
			mn = mmn;
			mx = mmx;
		}
		ans = max(ans,mx-mn);
		return ans;
	}
	
    long long mnds = (mx-mn)/N;
    vector < int > v;
    long long lst = mn;
    
    for(int i = mn; i <= mx; i+=mnds)
	   long long aa, bb;
       MinMax(i,i+mnds,&aa,&bb);
       if(aa != -1){
           ans = max(ans,aa-lst);
           lst = bb;
       }
	}
 
	return ans;
 
	return 0;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:37:15: warning: unused variable 'aa' [-Wunused-variable]
     long long aa, bb;
               ^
gap.cpp:37:19: warning: unused variable 'bb' [-Wunused-variable]
     long long aa, bb;
                   ^
gap.cpp:38:15: error: 'i' was not declared in this scope
        MinMax(i,i+mnds,&aa,&bb);
               ^
gap.cpp:38:25: error: 'aa' was not declared in this scope
        MinMax(i,i+mnds,&aa,&bb);
                         ^
gap.cpp:38:29: error: 'bb' was not declared in this scope
        MinMax(i,i+mnds,&aa,&bb);
                             ^
gap.cpp: At global scope:
gap.cpp:45:2: error: expected unqualified-id before 'return'
  return ans;
  ^
gap.cpp:47:2: error: expected unqualified-id before 'return'
  return 0;
  ^
gap.cpp:48:1: error: expected declaration before '}' token
 }
 ^
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:43:2: warning: control reaches end of non-void function [-Wreturn-type]
  }
  ^