답안 #102060

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
102060 2019-03-22T01:19:41 Z daniel920712 Detecting Molecules (IOI16_molecules) C++14
0 / 100
3 ms 384 KB
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
#include "molecules.h"

using namespace std;
struct A
{
    long long con;
    int where;
}all[200005];
bool F(A a,A b)
{
    return a.con<b.con;
}
vector < int > find_subset(int l, int u, vector < int > w)
{
    int N=w.size(),i;
    long long t;
    long long X=(long long) l;
    long long Y=(long long) u;
    int x=0,y=0;
    for(i=0;i<N;i++)
    {
        all[i].con=(long long) w[i];
        all[i].where=i;
    }
    sort(all,all+N,F);
    vector < int > ans;
    for(i=0;i<N;i++)
    {
        if(all[i].con>u) break;
        t+=all[i].con;
        while(t>Y)
        {
            t-=all[x++].con;
        }

        if(X<=t&&t<=Y)
        {
            //printf("%d %d %d %d\n",i,t,x,y);
            for(i=x;i<=y;i++)
            {
                //printf("a:%d\n",i);
                ans.push_back(all[i].where);

            }
            return ans;
        }


        y++;
    }


    return ans;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:35:10: warning: 't' may be used uninitialized in this function [-Wmaybe-uninitialized]
         t+=all[i].con;
         ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB OK (n = 1, answer = NO)
2 Correct 2 ms 384 KB OK (n = 1, answer = NO)
3 Incorrect 3 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 384 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB OK (n = 1, answer = NO)
2 Correct 2 ms 384 KB OK (n = 1, answer = NO)
3 Incorrect 3 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB OK (n = 1, answer = NO)
2 Correct 2 ms 384 KB OK (n = 1, answer = NO)
3 Incorrect 3 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB OK (n = 1, answer = NO)
2 Correct 2 ms 384 KB OK (n = 1, answer = NO)
3 Incorrect 3 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB OK (n = 1, answer = NO)
2 Correct 2 ms 384 KB OK (n = 1, answer = NO)
3 Incorrect 3 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -