#include "bartender.h"
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
typedef __int128 lll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
#define MAX 9223372036854775807LL
#define MIN -9223372036854775807LL
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout << fixed; cout.precision(10);
#define sp << " "
#define en << "\n"
#define compress(v) sort(v.begin(), v.end()), v.erase(unique(v.begin(), v.end()), v.end())
vector<ll> BlendWines(ll K, vector<ll> R)
{
ll n = (ll)R.size();
vector<ll> ret;
for(ll i = 0 ; i < n ; i++)
ret.push_back(0);
for(ll i = 0 ; i < n ; i++)
{
for(ll j = 0 ; j < n ; j++)
{
if(R[j] == i + 1)
ret[j] = i / 3 + 1;
}
}
return ret;
}
#include "taster.h"
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
typedef __int128 lll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
#define MAX 9223372036854775807LL
#define MIN -9223372036854775807LL
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout << fixed; cout.precision(10);
#define sp << " "
#define en << "\n"
#define compress(v) sort(v.begin(), v.end()), v.erase(unique(v.begin(), v.end()), v.end())
vector<int> SortWines(int K, vector<int> A)
{
ll maxx = 0;
ll n = (ll)A.size();
vector<ll> ans;
for(ll i = 0 ; i < n ; i++)
{
maxx = max(maxx, A[i]);
ans.push_back(0);
}
ll cc = 1;
for(ll i = 1 ; i <= maxx ; i++)
{
vector<ll> vec;
for(ll j = 0 ; j < n ; j++)
{
if(A[j] == i)
vec.push_back(j);
}
if((ll)vec.size() == 1)
ans[vec[0]] = cc++;
else if((ll)vec.size() == 2)
{
ll qry = Compare(vec[0], vec[1]);
if(qry == -1)
{
ans[vec[1]] = cc++;
ans[vec[0]] = cc++;
}
else
{
ans[vec[1]] = cc++;
ans[vec[0]] = cc++;
}
}
else if((ll)vec.size() == 3)
{
ll qry1 = Compare(vec[0], vec[1]);
ll qry2 = Compare(vec[0], vec[2]);
ll qry3 = Compare(vec[1], vec[2]);
ll sum = vec[0] + vec[1] + vec[2];
if(qry1 == 1 && qry2 == 1)
ans[vec[0]] = cc + 2, sum -= vec[0];
else if(qry1 == -1 && qry3 == 1)
ans[vec[1]] = cc + 2, sum -= vec[1];
else if(qry2 == -1 && qry3 == -1)
ans[vec[2]] = cc + 2, sum -= vec[2];
if(qry1 == -1 && qry2 == -1)
ans[vec[0]] = cc, sum -= vec[0];
else if(qry1 == 1 && qry3 == -1)
ans[vec[1]] = cc, sum -= vec[1];
else if(qry2 == 1 && qry3 == 1)
ans[vec[2]] = cc, sum -= vec[2];
ans[sum] = cc + 1;
cc += 3;
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
528 KB |
Correct |
2 |
Incorrect |
1 ms |
608 KB |
Wrong |
3 |
Halted |
0 ms |
0 KB |
- |