답안 #198372

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
198372 2020-01-25T17:39:06 Z Ruxandra985 Detecting Molecules (IOI16_molecules) C++14
10 / 100
2 ms 376 KB
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;

vector <int> sol;
pair <int,int> x[200010];
vector <int> find_subset (int l , int u , vector <int> v){
    int i , sum , j , k;
    for (i=0;i<v.size();i++){
        x[i] = make_pair(v[i] , i);
    }
    sort (x , x + v.size());


    sum = 0;
    j = -1;
    for (i=0 ; i < v.size() ; i++){
        sum -= x[i-1].first;
        if (j < i){
            j = i;
            sum += x[i].first;
        }
        while (j+1 < v.size()){
            sum += x[j+1].first;
            if (sum > u){
                sum -= x[j+1].first;
                break;
            }
            if (l <= sum && sum <= u){

                for (k = i ; k <= j + 1 ; k++){
                    sol.push_back(x[k].second);
                }

                return sol;
            }
            j++;
        }

    }

    sol.clear();

    return sol; /// nu se poate;

}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:9:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (i=0;i<v.size();i++){
              ~^~~~~~~~~
molecules.cpp:17:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (i=0 ; i < v.size() ; i++){
                ~~^~~~~~~~~~
molecules.cpp:23:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while (j+1 < v.size()){
                ~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB OK (n = 12, answer = YES)
2 Correct 1 ms 256 KB OK (n = 12, answer = YES)
3 Correct 2 ms 256 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 376 KB OK (n = 12, answer = YES)
7 Correct 2 ms 256 KB OK (n = 12, answer = YES)
8 Correct 2 ms 376 KB OK (n = 12, answer = YES)
9 Correct 2 ms 376 KB OK (n = 6, answer = YES)
10 Correct 2 ms 296 KB OK (n = 12, answer = YES)
11 Correct 2 ms 376 KB OK (n = 100, answer = NO)
12 Correct 2 ms 376 KB OK (n = 100, answer = YES)
13 Correct 2 ms 256 KB OK (n = 100, answer = NO)
14 Correct 2 ms 376 KB OK (n = 100, answer = YES)
15 Correct 2 ms 376 KB OK (n = 100, answer = YES)
16 Correct 2 ms 376 KB OK (n = 100, answer = YES)
17 Correct 2 ms 364 KB OK (n = 100, answer = YES)
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -