답안 #148768

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
148768 2019-09-01T05:05:06 Z 갓띵건(#3694, gs18103, sjimed, gs18065) King of Chairs (FXCUP4_chairs) C++17
100 / 100
195 ms 10508 KB
#include "king.h"
#include<bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(false);cin.tie(0)
#define fi first
#define se second
#define eb emplace_back
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define pre(a) cout<<fixed;cout.precision(a)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const int inf = 1e9;
const ll INF = 1e18;


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

	int idx = 0;
	int ret = 0;
	for(int i=0; i<W.size(); i++) {
		while(idx < C.size() && C[idx] < W[i]) idx++;
		if(C[idx] >= W[i]) ret = W[i];
	}

	return 0;
}
#include "vassal.h"
#include<bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(false);cin.tie(0)
#define fi first
#define se second
#define eb emplace_back
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define pre(a) cout<<fixed;cout.precision(a)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const int inf = 1e9;
const ll INF = 1e18;

int w;
set<pii> S;

void Init(long long B, std::vector<int> C){
	int N = C.size();
	w = B;

	for(int i=0; i<C.size(); i++) {
		S.insert({C[i], i});
	}
}

int Maid(int W){
	//if(W > w) return -1;
	set<pii>::iterator it = S.lower_bound({W, -1});
	if(it == S.end()) return -1;

	int ret = it -> se;
	S.erase(it);

	return ret;
}

Compilation message

king.cpp: In function 'long long int SendInfo(std::vector<int>, std::vector<int>)':
king.cpp:27:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<W.size(); i++) {
               ~^~~~~~~~~
king.cpp:28:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(idx < C.size() && C[idx] < W[i]) idx++;
         ~~~~^~~~~~~~~~
king.cpp:21:6: warning: unused variable 'N' [-Wunused-variable]
  int N = W.size();
      ^
king.cpp:26:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
  int ret = 0;
      ^~~

vassal.cpp: In function 'void Init(long long int, std::vector<int>)':
vassal.cpp:26:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<C.size(); i++) {
               ~^~~~~~~~~
vassal.cpp:23:6: warning: unused variable 'N' [-Wunused-variable]
  int N = C.size();
      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1044 KB Correct
2 Correct 11 ms 1048 KB Correct
3 Correct 10 ms 1048 KB Correct
4 Correct 10 ms 1044 KB Correct
5 Correct 10 ms 972 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 70 ms 5828 KB Correct
2 Correct 131 ms 9660 KB Correct
3 Correct 123 ms 10432 KB Correct
4 Correct 128 ms 10436 KB Correct
5 Correct 124 ms 10444 KB Correct
6 Correct 122 ms 10176 KB Correct
7 Correct 134 ms 10436 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 92 ms 5936 KB Correct
2 Correct 174 ms 9628 KB Correct
3 Correct 147 ms 10436 KB Correct
4 Correct 195 ms 10356 KB Correct
5 Correct 187 ms 10440 KB Correct
6 Correct 194 ms 10436 KB Correct
7 Correct 155 ms 10508 KB Correct
8 Correct 138 ms 10428 KB Correct