답안 #185392

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
185392 2020-01-11T12:36:11 Z oofsauce Detecting Molecules (IOI16_molecules) C++14
0 / 100
5 ms 504 KB
#include "molecules.h"
#include <bits/stdc++.h>

using namespace std;

vector<int> find_subset(int l, int u, vector<int> w) {
  vector<pair<int,int>> sorted;

  for(int i = 0; i < w.size(); i++) {
    sorted.push_back({w[i], i});
  }

  sort(sorted.begin(), sorted.end());

  int acc = 0;
  int b = sorted.size()-1, a = b;
  acc = sorted[b].first;
  while(acc < l) {
    if(a > 0) {
      a -= 1;
    }
    acc += sorted[a].first;
  }

  while(acc < l || acc > u) {
    if(a > 0) {
      acc -= sorted[b].first;
      a -= 1;
      b -= 1;
      acc += sorted[a].first;
    } else {
      return vector<int>(0);
    }
  }

  vector<int> range;
  for(int i = a; i <= b; i++) {
    range.push_back(sorted[i].second);
  }

  return range;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:9:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < w.size(); i++) {
                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB OK (n = 1, answer = NO)
2 Correct 2 ms 256 KB OK (n = 1, answer = NO)
3 Correct 2 ms 256 KB OK (n = 1, answer = YES)
4 Correct 3 ms 376 KB OK (n = 2, answer = YES)
5 Correct 2 ms 376 KB OK (n = 2, answer = YES)
6 Correct 2 ms 376 KB OK (n = 3, answer = YES)
7 Correct 0 ms 376 KB OK (n = 3, answer = YES)
8 Correct 4 ms 348 KB OK (n = 3, answer = YES)
9 Correct 2 ms 256 KB OK (n = 3, answer = YES)
10 Correct 2 ms 256 KB OK (n = 3, answer = YES)
11 Correct 5 ms 376 KB OK (n = 3, answer = YES)
12 Correct 2 ms 376 KB OK (n = 3, answer = YES)
13 Correct 2 ms 256 KB OK (n = 3, answer = NO)
14 Correct 2 ms 256 KB OK (n = 3, answer = YES)
15 Correct 3 ms 376 KB OK (n = 3, answer = YES)
16 Correct 2 ms 256 KB OK (n = 3, answer = NO)
17 Incorrect 2 ms 256 KB sum of weights should be in [16..20] but it is 15
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB OK (n = 12, answer = YES)
2 Correct 2 ms 256 KB OK (n = 12, answer = YES)
3 Correct 2 ms 376 KB OK (n = 12, answer = NO)
4 Correct 2 ms 256 KB OK (n = 12, answer = NO)
5 Correct 2 ms 376 KB OK (n = 12, answer = YES)
6 Correct 2 ms 256 KB OK (n = 12, answer = YES)
7 Correct 2 ms 376 KB OK (n = 12, answer = YES)
8 Correct 2 ms 376 KB OK (n = 12, answer = YES)
9 Correct 2 ms 256 KB OK (n = 6, answer = YES)
10 Correct 2 ms 376 KB OK (n = 12, answer = YES)
11 Incorrect 2 ms 376 KB sum of weights should be in [150..150] but it is 100
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB OK (n = 1, answer = NO)
2 Correct 2 ms 256 KB OK (n = 1, answer = NO)
3 Correct 2 ms 256 KB OK (n = 1, answer = YES)
4 Correct 3 ms 376 KB OK (n = 2, answer = YES)
5 Correct 2 ms 376 KB OK (n = 2, answer = YES)
6 Correct 2 ms 376 KB OK (n = 3, answer = YES)
7 Correct 0 ms 376 KB OK (n = 3, answer = YES)
8 Correct 4 ms 348 KB OK (n = 3, answer = YES)
9 Correct 2 ms 256 KB OK (n = 3, answer = YES)
10 Correct 2 ms 256 KB OK (n = 3, answer = YES)
11 Correct 5 ms 376 KB OK (n = 3, answer = YES)
12 Correct 2 ms 376 KB OK (n = 3, answer = YES)
13 Correct 2 ms 256 KB OK (n = 3, answer = NO)
14 Correct 2 ms 256 KB OK (n = 3, answer = YES)
15 Correct 3 ms 376 KB OK (n = 3, answer = YES)
16 Correct 2 ms 256 KB OK (n = 3, answer = NO)
17 Incorrect 2 ms 256 KB sum of weights should be in [16..20] but it is 15
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB OK (n = 1, answer = NO)
2 Correct 2 ms 256 KB OK (n = 1, answer = NO)
3 Correct 2 ms 256 KB OK (n = 1, answer = YES)
4 Correct 3 ms 376 KB OK (n = 2, answer = YES)
5 Correct 2 ms 376 KB OK (n = 2, answer = YES)
6 Correct 2 ms 376 KB OK (n = 3, answer = YES)
7 Correct 0 ms 376 KB OK (n = 3, answer = YES)
8 Correct 4 ms 348 KB OK (n = 3, answer = YES)
9 Correct 2 ms 256 KB OK (n = 3, answer = YES)
10 Correct 2 ms 256 KB OK (n = 3, answer = YES)
11 Correct 5 ms 376 KB OK (n = 3, answer = YES)
12 Correct 2 ms 376 KB OK (n = 3, answer = YES)
13 Correct 2 ms 256 KB OK (n = 3, answer = NO)
14 Correct 2 ms 256 KB OK (n = 3, answer = YES)
15 Correct 3 ms 376 KB OK (n = 3, answer = YES)
16 Correct 2 ms 256 KB OK (n = 3, answer = NO)
17 Incorrect 2 ms 256 KB sum of weights should be in [16..20] but it is 15
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB OK (n = 1, answer = NO)
2 Correct 2 ms 256 KB OK (n = 1, answer = NO)
3 Correct 2 ms 256 KB OK (n = 1, answer = YES)
4 Correct 3 ms 376 KB OK (n = 2, answer = YES)
5 Correct 2 ms 376 KB OK (n = 2, answer = YES)
6 Correct 2 ms 376 KB OK (n = 3, answer = YES)
7 Correct 0 ms 376 KB OK (n = 3, answer = YES)
8 Correct 4 ms 348 KB OK (n = 3, answer = YES)
9 Correct 2 ms 256 KB OK (n = 3, answer = YES)
10 Correct 2 ms 256 KB OK (n = 3, answer = YES)
11 Correct 5 ms 376 KB OK (n = 3, answer = YES)
12 Correct 2 ms 376 KB OK (n = 3, answer = YES)
13 Correct 2 ms 256 KB OK (n = 3, answer = NO)
14 Correct 2 ms 256 KB OK (n = 3, answer = YES)
15 Correct 3 ms 376 KB OK (n = 3, answer = YES)
16 Correct 2 ms 256 KB OK (n = 3, answer = NO)
17 Incorrect 2 ms 256 KB sum of weights should be in [16..20] but it is 15
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB OK (n = 1, answer = NO)
2 Correct 2 ms 256 KB OK (n = 1, answer = NO)
3 Correct 2 ms 256 KB OK (n = 1, answer = YES)
4 Correct 3 ms 376 KB OK (n = 2, answer = YES)
5 Correct 2 ms 376 KB OK (n = 2, answer = YES)
6 Correct 2 ms 376 KB OK (n = 3, answer = YES)
7 Correct 0 ms 376 KB OK (n = 3, answer = YES)
8 Correct 4 ms 348 KB OK (n = 3, answer = YES)
9 Correct 2 ms 256 KB OK (n = 3, answer = YES)
10 Correct 2 ms 256 KB OK (n = 3, answer = YES)
11 Correct 5 ms 376 KB OK (n = 3, answer = YES)
12 Correct 2 ms 376 KB OK (n = 3, answer = YES)
13 Correct 2 ms 256 KB OK (n = 3, answer = NO)
14 Correct 2 ms 256 KB OK (n = 3, answer = YES)
15 Correct 3 ms 376 KB OK (n = 3, answer = YES)
16 Correct 2 ms 256 KB OK (n = 3, answer = NO)
17 Incorrect 2 ms 256 KB sum of weights should be in [16..20] but it is 15
18 Halted 0 ms 0 KB -