답안 #145063

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
145063 2019-08-18T16:30:01 Z Nightlight Detecting Molecules (IOI16_molecules) C++14
0 / 100
2 ms 376 KB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> ans;

vector<int> find_subset(int l, int u, vector<int> w) {
  sort(w.begin(), w.end());
  int min = w[0];int N = w.size();
  int sum = w[0];
  int low = 0, up = 0;
  while((sum < l || sum > u) && up < N){
    if(low > up)break;
    if(sum < l){
      up++;
      sum += w[up];
    }else if(sum > u){
      sum -= w[low];
      low++;
    }
//    cout << low << " " << up << " " << sum << "\n";
  }
  if(l <= sum && sum <= u){
    for(int i = low; i <= up; i++){
      ans.push_back(w[i]);
    }
    return ans;
  }
  return vector<int>(0);
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:9:7: warning: unused variable 'min' [-Wunused-variable]
   int min = w[0];int N = w.size();
       ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Integer 50 violates the range [0, 11]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -