제출 #883100

#제출 시각아이디문제언어결과실행 시간메모리
883100HusaynDetecting Molecules (IOI16_molecules)C++14
100 / 100
128 ms27480 KiB
#include "molecules.h"
#include <bits/stdc++.h> 
typedef long long ll;
 
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
  int n = (int) w.size();
  std::vector<std::pair<int, int>> a(n);
  for (int i = 0; i < n; i++) {
    a[i] = {w[i], i};
  }
  std::sort(a.begin(), a.end());
  
  std::set<ll> st;
  std::map<ll, int> pos;
  ll s = 0;
  st.insert(0);
  pos[0] = -1;
  for (int i = 0; i < n; i++) {
    auto [value, idx] = a[i];
    s += value;
    auto it = *st.lower_bound(s - u);
    if (it <= s - l) {
      std::vector<int> ret;
      for (int j = pos[it] + 1; j <= i; j++) {
        ret.push_back(a[j].second);
      }
      return ret;
    }
    st.insert(s);
    pos[s] = i;
  }
  return {};
}

컴파일 시 표준 에러 (stderr) 메시지

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:19:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   19 |     auto [value, idx] = a[i];
      |          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...