답안 #150551

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
150551 2019-09-01T08:37:28 Z 준표야 함수컵은 캐리해줄거지?(#3588, Acka, spectaclehong, heiler) King of Chairs (FXCUP4_chairs) C++17
컴파일 오류
0 ms 0 KB
#include "king.h"
#include <algorithm>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

long long SendInfo(std::vector<int> W, std::vector<int> C) {
	int N = W.size();

	vector<pii> ws, cs;
	for(int i=0;i<N;i++) {
	  cs.push_back({C[i], i});
	}
	sort(cs.begin(), cs.end());

	for(int i=0;i<N;i++) {
	  ws.push_back({W[i], i});
	}
	sort(ws.begin(), ws.end());

	int *ans = new[N];

	int wi=0;
	int ci=0;
	for(;wi<N && ci<N;) {
	  while(ci<N && ws[wi].first>cs[ci].first) {
	     ci++;
	  }
	  if(ci==N) break;
	  
	  ans[ws[wi].second] = cs[ci].second;
	  wi++; ci++;
	}
	for(int i=wi;i<N;i++)
	  ans[ws[i].second] = -1;
	
	ll ret = 0;
	for(int i = 0; i < N; i++)
		ret = ret * 11 + (ans[i] + 1);
	return ret;	
	// return ((unsigned long long)ans % (1ll << 32));
}
#include "vassal.h"
using namespace std;

int last, ans[100000];

void Init(long long B, std::vector<int> C){
	int N = C.size();
	for(int i = N - 1; i >= 0; i--){
		ans[i] = B % 11;
		B = (B - ans[i]) / 11;
		ans[i]--;
	}
}

int Maid(int W){
	return ans[last];
}

Compilation message

king.cpp: In function 'long long int SendInfo(std::vector<int>, std::vector<int>)':
king.cpp:22:16: error: expected type-specifier before '[' token
  int *ans = new[N];
                ^