Submission #150854

#TimeUsernameProblemLanguageResultExecution timeMemory
150854Weeeee (#200)Wine Tasting (FXCUP4_wine)C++17
0 / 100
10 ms908 KiB
#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] <= 24) res[i] = i / 4 + 1; else res[i] = i - 17; 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 (stderr)

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;
  ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...