답안 #150905

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
150905 2019-09-01T10:28:20 Z Alexa2001 포도주 시음 (FXCUP4_wine) C++17
49 / 100
12 ms 1044 KB
#include "bartender.h"
#include <bits/stdc++.h>

using namespace std;

std::vector<int> BlendWines(int K, std::vector<int> R)
{
    int i, n = R.size();
    vector<int> res(n);

    for(i=0; i<n; ++i)
        if(R[i] <= 23) res[i] = (R[i] - 1) / 4 + 1;
            else res[i] = R[i] - 18;

    for(i=0; i<n; ++i)
        if(res[i] > K) res[i] = K;
    return res;
}
#include "taster.h"
#include <bits/stdc++.h>

using namespace std;

vector<int> vec[30];
vector<int> alch;
int KK;

int MyCompare(int x, int y)
{
    if(alch[x] + alch[y] <= KK) return Compare(x, y);
    return -1;
}

void Sort(vector<int> &v)
{
    int n = v.size();
    if(n <= 1) return;

    int mid = n / 2;

    int i, j;
    vector<int> A, B;
    for(i=0; i<mid; ++i) A.push_back(v[i]);
    for(; i<n; ++i) B.push_back(v[i]);

    Sort(A); Sort(B);

    v.clear();

    i = 0; j = 0;
    while(v.size() < n)
    {
        if(j == B.size())
            v.push_back(A[i++]);
        else if(i == A.size())
            v.push_back(B[j++]);
        else if(MyCompare(A[i], B[j]) == -1)
            v.push_back(A[i++]);
        else v.push_back(B[j++]);
    }
}

vector<int> SortWines(int K, std::vector<int> A)
{
	int n = A.size();
    int i;

    KK = K;
    alch = A;

    for(i=0; i<n; ++i)
        vec[A[i]].push_back(i);

    for(i=1; i<=12; ++i)
        Sort(vec[i]);

    vector<int> res;

    for(i=1; i<=12; ++i)
        for(auto it : vec[i])
            res.push_back(it);

    vector<int> ans(n);
    for(i=0; i<n; ++i)
        ans[res[i]] = i+1;
	return ans;
}

Compilation message

taster.cpp: In function 'void Sort(std::vector<int>&)':
taster.cpp:33:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(v.size() < n)
           ~~~~~~~~~^~~
taster.cpp:35:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(j == B.size())
            ~~^~~~~~~~~~~
taster.cpp:37:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         else if(i == A.size())
                 ~~^~~~~~~~~~~
taster.cpp: In function 'std::vector<int> SortWines(int, std::vector<int>)':
taster.cpp:66:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for(i=0; i<n; ++i)
     ^~~
taster.cpp:68:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  return ans;
  ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 780 KB Correct
2 Correct 10 ms 772 KB Correct
3 Correct 10 ms 1016 KB Correct
4 Correct 10 ms 784 KB Correct
5 Correct 10 ms 1008 KB Correct
6 Correct 10 ms 772 KB Correct
7 Correct 10 ms 772 KB Correct
8 Correct 10 ms 772 KB Correct
9 Correct 10 ms 908 KB Correct
10 Correct 10 ms 772 KB Correct
11 Correct 10 ms 772 KB Correct
12 Correct 10 ms 772 KB Correct
13 Correct 9 ms 696 KB Correct
14 Correct 10 ms 772 KB Correct
15 Correct 10 ms 772 KB Correct
16 Correct 12 ms 772 KB Correct
17 Correct 10 ms 772 KB Correct
18 Correct 9 ms 644 KB Correct
19 Correct 10 ms 908 KB Correct
20 Correct 9 ms 780 KB Correct
21 Correct 10 ms 784 KB Correct
22 Correct 10 ms 772 KB Correct
23 Correct 10 ms 908 KB Correct
24 Correct 10 ms 908 KB Correct
25 Correct 9 ms 908 KB Correct
26 Correct 8 ms 772 KB Correct
27 Correct 12 ms 772 KB Correct
28 Correct 10 ms 788 KB Correct
29 Correct 10 ms 772 KB Correct
30 Correct 9 ms 644 KB Correct
31 Correct 10 ms 772 KB Correct
32 Correct 9 ms 772 KB Correct
33 Correct 9 ms 772 KB Correct
34 Correct 10 ms 800 KB Correct
35 Correct 9 ms 780 KB Correct
36 Correct 10 ms 772 KB Correct
37 Correct 9 ms 772 KB Correct
38 Correct 10 ms 772 KB Correct
39 Correct 10 ms 908 KB Correct
40 Correct 9 ms 884 KB Correct
41 Correct 9 ms 644 KB Correct
42 Correct 10 ms 908 KB Correct
43 Correct 10 ms 772 KB Correct
44 Correct 10 ms 772 KB Correct
45 Correct 9 ms 908 KB Correct
46 Correct 10 ms 772 KB Correct
47 Correct 9 ms 772 KB Correct
48 Correct 9 ms 644 KB Correct
49 Correct 9 ms 780 KB Correct
50 Correct 10 ms 772 KB Correct
51 Correct 10 ms 908 KB Correct
52 Correct 10 ms 772 KB Correct
53 Correct 9 ms 772 KB Correct
54 Correct 10 ms 772 KB Correct
55 Correct 10 ms 772 KB Correct
56 Correct 10 ms 772 KB Correct
57 Correct 9 ms 772 KB Correct
58 Correct 10 ms 868 KB Correct
59 Correct 10 ms 908 KB Correct
60 Correct 9 ms 908 KB Correct
61 Correct 9 ms 772 KB Correct
62 Correct 10 ms 772 KB Correct
63 Correct 10 ms 772 KB Correct
64 Correct 10 ms 960 KB Correct
65 Correct 9 ms 908 KB Correct
66 Correct 10 ms 908 KB Correct
67 Correct 10 ms 772 KB Correct
68 Correct 10 ms 908 KB Correct
69 Correct 10 ms 772 KB Correct
70 Partially correct 10 ms 772 KB Wrong
71 Partially correct 9 ms 772 KB Wrong
72 Partially correct 9 ms 772 KB Wrong
73 Partially correct 9 ms 780 KB Wrong
74 Partially correct 10 ms 780 KB Wrong
75 Partially correct 9 ms 644 KB Wrong
76 Correct 10 ms 664 KB Correct
77 Correct 9 ms 772 KB Correct
78 Correct 10 ms 772 KB Correct
79 Correct 10 ms 772 KB Correct
80 Correct 10 ms 908 KB Correct
81 Partially correct 10 ms 908 KB Wrong
82 Partially correct 8 ms 644 KB Wrong
83 Partially correct 9 ms 780 KB Wrong
84 Partially correct 9 ms 644 KB Wrong
85 Partially correct 11 ms 908 KB Wrong
86 Partially correct 10 ms 772 KB Wrong
87 Correct 9 ms 772 KB Correct
88 Correct 10 ms 756 KB Correct
89 Correct 10 ms 924 KB Correct
90 Correct 9 ms 780 KB Correct
91 Correct 9 ms 644 KB Correct
92 Correct 9 ms 772 KB Correct
93 Partially correct 10 ms 772 KB Wrong
94 Partially correct 10 ms 908 KB Wrong
95 Partially correct 9 ms 772 KB Wrong
96 Partially correct 10 ms 772 KB Wrong
97 Partially correct 10 ms 772 KB Wrong
98 Partially correct 10 ms 908 KB Wrong
99 Partially correct 10 ms 772 KB Wrong
100 Partially correct 10 ms 772 KB Wrong
101 Partially correct 10 ms 772 KB Wrong
102 Correct 10 ms 708 KB Correct
103 Correct 10 ms 772 KB Correct
104 Correct 9 ms 772 KB Correct
105 Correct 9 ms 908 KB Correct
106 Correct 9 ms 772 KB Correct
107 Partially correct 12 ms 772 KB Wrong
108 Partially correct 9 ms 1044 KB Wrong
109 Partially correct 9 ms 780 KB Wrong
110 Partially correct 10 ms 908 KB Wrong
111 Partially correct 10 ms 908 KB Wrong
112 Partially correct 9 ms 644 KB Wrong
113 Partially correct 10 ms 772 KB Wrong
114 Partially correct 10 ms 820 KB Wrong
115 Partially correct 10 ms 772 KB Wrong
116 Partially correct 11 ms 772 KB Wrong
117 Correct 10 ms 884 KB Correct
118 Partially correct 9 ms 908 KB Wrong
119 Partially correct 10 ms 772 KB Wrong
120 Partially correct 8 ms 772 KB Wrong