#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++)
ret[i] = (R[i] - 1) % 10 + 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++)
{
ans.push_back(0);
maxx = max(maxx, A[i]);
}
vector<ll> on, son;
for(ll i = 0 ; i < n ; i++)
{
if(A[i] == 1)
on.push_back(i);
}
if((ll)on.size() == 1)
son = on;
else if((ll)on.size() == 2)
{
ll qry = Compare(on[0], on[1]);
if(qry == -1)
{
son.push_back(on[0]);
son.push_back(on[1]);
}
else
{
son.push_back(on[1]);
son.push_back(on[0]);
}
}
else
{
ll qry1 = Compare(on[0], on[1]);
ll qry2 = Compare(on[0], on[2]);
ll qry3 = Compare(on[1], on[2]);
ll sum = on[0] + on[1] + on[2];
ll w1 = 0, w3 = 0;
if(qry1 == 1 && qry2 == 1)
w3 = on[0], sum -= on[0];
else if(qry1 == -1 && qry3 == 1)
w3 = on[1], sum -= on[1];
else if(qry2 == -1 && qry3 == -1)
w3 = on[2], sum -= on[2];
if(qry1 == -1 && qry2 == -1)
w1 = on[0], sum -= on[0];
else if(qry1 == 1 && qry3 == -1)
w1 = on[1], sum -= on[1];
else if(qry2 == 1 && qry3 == 1)
w1 = on[2], sum -= on[2];
son.push_back(w1);
son.push_back(sum);
son.push_back(w3);
}
for(ll i = 0 ; i < (ll)son.size() ; i++)
ans[son[i]] = i * 10 + 1;
for(ll i = 2 ; i <= maxx ; i++)
{
vector<ll> w;
for(ll j = 0 ; j < n ; j++)
{
if(A[j] == i)
w.push_back(j);
}
if((ll)w.size() == 1)
{
ans[w[0]] = i;
continue;
}
if(son.size() == 2)
{
ll qry1 = Compare(son[1], w[0]);
if(qry1 == -1)
{
ans[w[0]] = 10 + i;
if((ll)w.size() >= 2)
ans[w[1]] = i;
}
else
{
ans[w[0]] = i;
if((ll)w.size() >= 2)
ans[w[1]] = 10 + i;
}
}
else
{
vector<ll> tmp = son;
vector<ll> help;
help.push_back(0);
help.push_back(10);
help.push_back(20);
for(ll j = 0 ; j < (ll)w.size() ; j++)
{
if((ll)tmp.size() == 3)
{
ll qry = Compare(tmp[1], w[j]);
if(qry == 1)
{
ans[w[j]] = i + help[0];
tmp[0] = tmp[1];
tmp[1] = tmp[2];
tmp.pop_back();
help[0] = help[1];
help[1] = help[2];
help.pop_back();
continue;
}
qry = Compare(tmp[2], w[j]);
if(qry == -1)
{
ans[w[j]] = i + help[2];
tmp.pop_back();
help.pop_back();
}
else
{
ans[w[j]] = i + help[1];
tmp[1] = tmp[2];
tmp.pop_back();
help[1] = help[2];
help.pop_back();
}
}
else if((ll)tmp.size() == 2)
{
ll qry = Compare(tmp[1], w[j]);
if(qry == 1)
{
ans[w[j]] = i + help[0];
tmp[0] = tmp[1];
tmp.pop_back();
help[0] = help[1];
help.pop_back();
}
else
{
ans[w[j]] = i + help[1];
tmp.pop_back();
help.pop_back();
}
}
else
ans[w[j]] = i + help[0];
}
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
508 KB |
Correct |
2 |
Correct |
1 ms |
508 KB |
Correct |
3 |
Correct |
0 ms |
512 KB |
Correct |
4 |
Correct |
0 ms |
508 KB |
Correct |
5 |
Correct |
0 ms |
508 KB |
Correct |
6 |
Correct |
1 ms |
508 KB |
Correct |
7 |
Correct |
0 ms |
516 KB |
Correct |
8 |
Correct |
0 ms |
516 KB |
Correct |
9 |
Correct |
1 ms |
508 KB |
Correct |
10 |
Correct |
0 ms |
508 KB |
Correct |
11 |
Correct |
1 ms |
508 KB |
Correct |
12 |
Correct |
1 ms |
508 KB |
Correct |
13 |
Correct |
1 ms |
508 KB |
Correct |
14 |
Correct |
0 ms |
508 KB |
Correct |
15 |
Correct |
0 ms |
508 KB |
Correct |
16 |
Correct |
0 ms |
508 KB |
Correct |
17 |
Correct |
0 ms |
508 KB |
Correct |
18 |
Correct |
1 ms |
604 KB |
Correct |
19 |
Correct |
0 ms |
508 KB |
Correct |
20 |
Correct |
0 ms |
508 KB |
Correct |
21 |
Correct |
1 ms |
508 KB |
Correct |
22 |
Correct |
1 ms |
516 KB |
Correct |
23 |
Correct |
1 ms |
508 KB |
Correct |
24 |
Correct |
0 ms |
508 KB |
Correct |
25 |
Correct |
0 ms |
516 KB |
Correct |
26 |
Correct |
0 ms |
516 KB |
Correct |
27 |
Correct |
1 ms |
508 KB |
Correct |
28 |
Correct |
1 ms |
508 KB |
Correct |
29 |
Correct |
0 ms |
516 KB |
Correct |
30 |
Correct |
0 ms |
508 KB |
Correct |
31 |
Correct |
1 ms |
516 KB |
Correct |
32 |
Correct |
0 ms |
516 KB |
Correct |
33 |
Correct |
1 ms |
508 KB |
Correct |
34 |
Correct |
0 ms |
508 KB |
Correct |
35 |
Correct |
1 ms |
508 KB |
Correct |
36 |
Correct |
1 ms |
508 KB |
Correct |
37 |
Correct |
0 ms |
516 KB |
Correct |
38 |
Correct |
1 ms |
512 KB |
Correct |
39 |
Correct |
2 ms |
508 KB |
Correct |
40 |
Correct |
0 ms |
516 KB |
Correct |
41 |
Correct |
0 ms |
508 KB |
Correct |
42 |
Correct |
0 ms |
508 KB |
Correct |
43 |
Correct |
1 ms |
508 KB |
Correct |
44 |
Correct |
0 ms |
516 KB |
Correct |
45 |
Correct |
0 ms |
508 KB |
Correct |
46 |
Correct |
0 ms |
520 KB |
Correct |
47 |
Correct |
1 ms |
516 KB |
Correct |
48 |
Correct |
0 ms |
516 KB |
Correct |
49 |
Correct |
1 ms |
508 KB |
Correct |
50 |
Correct |
1 ms |
516 KB |
Correct |
51 |
Correct |
1 ms |
508 KB |
Correct |
52 |
Correct |
0 ms |
516 KB |
Correct |
53 |
Correct |
1 ms |
508 KB |
Correct |
54 |
Correct |
0 ms |
508 KB |
Correct |
55 |
Correct |
1 ms |
508 KB |
Correct |
56 |
Correct |
0 ms |
508 KB |
Correct |
57 |
Correct |
0 ms |
508 KB |
Correct |
58 |
Correct |
1 ms |
508 KB |
Correct |
59 |
Correct |
0 ms |
508 KB |
Correct |
60 |
Correct |
0 ms |
508 KB |
Correct |
61 |
Correct |
0 ms |
504 KB |
Correct |
62 |
Correct |
1 ms |
516 KB |
Correct |
63 |
Correct |
0 ms |
512 KB |
Correct |
64 |
Correct |
0 ms |
516 KB |
Correct |
65 |
Correct |
2 ms |
516 KB |
Correct |
66 |
Correct |
1 ms |
508 KB |
Correct |
67 |
Correct |
1 ms |
508 KB |
Correct |
68 |
Correct |
0 ms |
516 KB |
Correct |
69 |
Correct |
0 ms |
516 KB |
Correct |
70 |
Correct |
1 ms |
508 KB |
Correct |
71 |
Correct |
1 ms |
508 KB |
Correct |
72 |
Correct |
0 ms |
508 KB |
Correct |
73 |
Partially correct |
0 ms |
508 KB |
Wrong |
74 |
Partially correct |
1 ms |
508 KB |
Wrong |
75 |
Partially correct |
1 ms |
508 KB |
Wrong |
76 |
Correct |
0 ms |
504 KB |
Correct |
77 |
Correct |
0 ms |
508 KB |
Correct |
78 |
Correct |
0 ms |
508 KB |
Correct |
79 |
Partially correct |
0 ms |
508 KB |
Wrong |
80 |
Partially correct |
0 ms |
508 KB |
Wrong |
81 |
Partially correct |
0 ms |
516 KB |
Wrong |
82 |
Partially correct |
0 ms |
516 KB |
Wrong |
83 |
Partially correct |
1 ms |
508 KB |
Wrong |
84 |
Partially correct |
1 ms |
508 KB |
Wrong |
85 |
Partially correct |
1 ms |
508 KB |
Wrong |
86 |
Partially correct |
0 ms |
508 KB |
Wrong |
87 |
Partially correct |
0 ms |
508 KB |
Wrong |
88 |
Correct |
0 ms |
508 KB |
Correct |
89 |
Correct |
1 ms |
516 KB |
Correct |
90 |
Correct |
0 ms |
508 KB |
Correct |
91 |
Partially correct |
0 ms |
508 KB |
Wrong |
92 |
Partially correct |
1 ms |
508 KB |
Wrong |
93 |
Partially correct |
0 ms |
516 KB |
Wrong |
94 |
Partially correct |
1 ms |
516 KB |
Wrong |
95 |
Partially correct |
1 ms |
516 KB |
Wrong |
96 |
Partially correct |
1 ms |
508 KB |
Wrong |
97 |
Partially correct |
0 ms |
516 KB |
Wrong |
98 |
Partially correct |
0 ms |
508 KB |
Wrong |
99 |
Partially correct |
0 ms |
508 KB |
Wrong |
100 |
Partially correct |
0 ms |
508 KB |
Wrong |
101 |
Partially correct |
0 ms |
508 KB |
Wrong |
102 |
Partially correct |
0 ms |
508 KB |
Wrong |
103 |
Correct |
0 ms |
520 KB |
Correct |
104 |
Correct |
0 ms |
508 KB |
Correct |
105 |
Correct |
1 ms |
508 KB |
Correct |
106 |
Partially correct |
0 ms |
508 KB |
Wrong |
107 |
Partially correct |
1 ms |
508 KB |
Wrong |
108 |
Partially correct |
2 ms |
508 KB |
Wrong |
109 |
Partially correct |
0 ms |
508 KB |
Wrong |
110 |
Partially correct |
0 ms |
516 KB |
Wrong |
111 |
Partially correct |
2 ms |
508 KB |
Wrong |
112 |
Partially correct |
0 ms |
512 KB |
Wrong |
113 |
Partially correct |
1 ms |
516 KB |
Wrong |
114 |
Partially correct |
1 ms |
516 KB |
Wrong |
115 |
Partially correct |
1 ms |
508 KB |
Wrong |
116 |
Partially correct |
1 ms |
508 KB |
Wrong |
117 |
Partially correct |
0 ms |
508 KB |
Wrong |
118 |
Partially correct |
1 ms |
508 KB |
Wrong |
119 |
Partially correct |
0 ms |
508 KB |
Wrong |
120 |
Partially correct |
0 ms |
508 KB |
Wrong |