답안 #74172

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
74172 2018-08-30T11:01:41 Z renatsj Detecting Molecules (IOI16_molecules) C++14
9 / 100
2 ms 752 KB
#include<bits/stdc++.h>
#include "molecules.h"
struct masivs{int val;int poz;};
masivs ab[1000006];
using namespace std;
int i,j,k,n,m,sum,pref[1000006],suff[1000006];
vector<int> xx;
vector<int> xcur,xnew;
list<int> vv;
bool c1(masivs maz,masivs liel)
{
    if (maz.val==liel.val)
    {
        return maz.poz<liel.poz;
    }
    return maz.val>liel.val;
}
vector<int> find_subset(int l, int u, vector<int> w)
{
    n=w.size();
    i=0;
    while (i<n)
    {
        ab[i].val=w[i];
        ab[i].poz=i;
        i++;
    }
    sort(ab,ab+n,c1);
    pref[0]=ab[0].val;
    i=1;
    while (i<n)
    {
        pref[i]=pref[i-1]+ab[i].val;
        i++;
    }
    i=n-1;
    while (i>=0)
    {
        suff[i]=suff[i+1]+ab[i].val;
        i--;
    }
    k=0;
    while (k<n)
    {
        //cout << pref[k] << " " << suff[n-k-1] << "\n";
        if (pref[k]>u&&suff[n-k-1]<=l)
        {
            sum=0;
            i=0;
            while (i<=k)
            {
                sum+=ab[i].val;
                vv.push_back(ab[i].poz);
                i++;
            }
            j=0;
            while (sum>u)
            {
                sum+=ab[i].val;
                vv.push_back(ab[i].poz);
                sum-=ab[j].val;
                vv.pop_front();
                i++;
                j--;
            }
            for (int j:vv)
            {
                xx.push_back(j);
            }
            return xx;
        }
        if (pref[k]<=u&&pref[k]>=l)
        {
            i=0;
            sum=0;
            while (sum<l)
            {
                sum+=ab[i].val;
                xx.push_back(ab[i].poz);
                i++;
            }
            return xx;
        }
        if (suff[n-k-1]<=u&&suff[n-k-1]>=l)
        {
            i=n-1;
            sum=0;
            while (sum<l)
            {
                sum+=ab[i].val;
                xx.push_back(ab[i].poz);
                i--;
            }
            return xx;
        }
        k++;
    }
    return vector<int>(0);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 508 KB OK (n = 1, answer = NO)
3 Correct 2 ms 508 KB OK (n = 1, answer = YES)
4 Correct 2 ms 508 KB OK (n = 2, answer = YES)
5 Correct 2 ms 508 KB OK (n = 2, answer = YES)
6 Correct 2 ms 508 KB OK (n = 3, answer = YES)
7 Correct 2 ms 548 KB OK (n = 3, answer = YES)
8 Correct 2 ms 560 KB OK (n = 3, answer = YES)
9 Correct 2 ms 672 KB OK (n = 3, answer = YES)
10 Correct 2 ms 672 KB OK (n = 3, answer = YES)
11 Correct 2 ms 672 KB OK (n = 3, answer = YES)
12 Correct 2 ms 720 KB OK (n = 3, answer = YES)
13 Correct 2 ms 720 KB OK (n = 3, answer = NO)
14 Correct 2 ms 720 KB OK (n = 3, answer = YES)
15 Correct 2 ms 720 KB OK (n = 3, answer = YES)
16 Correct 2 ms 720 KB OK (n = 3, answer = NO)
17 Correct 2 ms 752 KB OK (n = 3, answer = NO)
18 Correct 2 ms 752 KB OK (n = 100, answer = NO)
19 Correct 2 ms 752 KB OK (n = 100, answer = YES)
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 752 KB sum of weights should be in [302..304] but it is 300
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 508 KB OK (n = 1, answer = NO)
3 Correct 2 ms 508 KB OK (n = 1, answer = YES)
4 Correct 2 ms 508 KB OK (n = 2, answer = YES)
5 Correct 2 ms 508 KB OK (n = 2, answer = YES)
6 Correct 2 ms 508 KB OK (n = 3, answer = YES)
7 Correct 2 ms 548 KB OK (n = 3, answer = YES)
8 Correct 2 ms 560 KB OK (n = 3, answer = YES)
9 Correct 2 ms 672 KB OK (n = 3, answer = YES)
10 Correct 2 ms 672 KB OK (n = 3, answer = YES)
11 Correct 2 ms 672 KB OK (n = 3, answer = YES)
12 Correct 2 ms 720 KB OK (n = 3, answer = YES)
13 Correct 2 ms 720 KB OK (n = 3, answer = NO)
14 Correct 2 ms 720 KB OK (n = 3, answer = YES)
15 Correct 2 ms 720 KB OK (n = 3, answer = YES)
16 Correct 2 ms 720 KB OK (n = 3, answer = NO)
17 Correct 2 ms 752 KB OK (n = 3, answer = NO)
18 Correct 2 ms 752 KB OK (n = 100, answer = NO)
19 Correct 2 ms 752 KB OK (n = 100, answer = YES)
20 Incorrect 2 ms 752 KB sum of weights should be in [302..304] but it is 300
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 508 KB OK (n = 1, answer = NO)
3 Correct 2 ms 508 KB OK (n = 1, answer = YES)
4 Correct 2 ms 508 KB OK (n = 2, answer = YES)
5 Correct 2 ms 508 KB OK (n = 2, answer = YES)
6 Correct 2 ms 508 KB OK (n = 3, answer = YES)
7 Correct 2 ms 548 KB OK (n = 3, answer = YES)
8 Correct 2 ms 560 KB OK (n = 3, answer = YES)
9 Correct 2 ms 672 KB OK (n = 3, answer = YES)
10 Correct 2 ms 672 KB OK (n = 3, answer = YES)
11 Correct 2 ms 672 KB OK (n = 3, answer = YES)
12 Correct 2 ms 720 KB OK (n = 3, answer = YES)
13 Correct 2 ms 720 KB OK (n = 3, answer = NO)
14 Correct 2 ms 720 KB OK (n = 3, answer = YES)
15 Correct 2 ms 720 KB OK (n = 3, answer = YES)
16 Correct 2 ms 720 KB OK (n = 3, answer = NO)
17 Correct 2 ms 752 KB OK (n = 3, answer = NO)
18 Correct 2 ms 752 KB OK (n = 100, answer = NO)
19 Correct 2 ms 752 KB OK (n = 100, answer = YES)
20 Incorrect 2 ms 752 KB sum of weights should be in [302..304] but it is 300
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 508 KB OK (n = 1, answer = NO)
3 Correct 2 ms 508 KB OK (n = 1, answer = YES)
4 Correct 2 ms 508 KB OK (n = 2, answer = YES)
5 Correct 2 ms 508 KB OK (n = 2, answer = YES)
6 Correct 2 ms 508 KB OK (n = 3, answer = YES)
7 Correct 2 ms 548 KB OK (n = 3, answer = YES)
8 Correct 2 ms 560 KB OK (n = 3, answer = YES)
9 Correct 2 ms 672 KB OK (n = 3, answer = YES)
10 Correct 2 ms 672 KB OK (n = 3, answer = YES)
11 Correct 2 ms 672 KB OK (n = 3, answer = YES)
12 Correct 2 ms 720 KB OK (n = 3, answer = YES)
13 Correct 2 ms 720 KB OK (n = 3, answer = NO)
14 Correct 2 ms 720 KB OK (n = 3, answer = YES)
15 Correct 2 ms 720 KB OK (n = 3, answer = YES)
16 Correct 2 ms 720 KB OK (n = 3, answer = NO)
17 Correct 2 ms 752 KB OK (n = 3, answer = NO)
18 Correct 2 ms 752 KB OK (n = 100, answer = NO)
19 Correct 2 ms 752 KB OK (n = 100, answer = YES)
20 Incorrect 2 ms 752 KB sum of weights should be in [302..304] but it is 300
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 508 KB OK (n = 1, answer = NO)
3 Correct 2 ms 508 KB OK (n = 1, answer = YES)
4 Correct 2 ms 508 KB OK (n = 2, answer = YES)
5 Correct 2 ms 508 KB OK (n = 2, answer = YES)
6 Correct 2 ms 508 KB OK (n = 3, answer = YES)
7 Correct 2 ms 548 KB OK (n = 3, answer = YES)
8 Correct 2 ms 560 KB OK (n = 3, answer = YES)
9 Correct 2 ms 672 KB OK (n = 3, answer = YES)
10 Correct 2 ms 672 KB OK (n = 3, answer = YES)
11 Correct 2 ms 672 KB OK (n = 3, answer = YES)
12 Correct 2 ms 720 KB OK (n = 3, answer = YES)
13 Correct 2 ms 720 KB OK (n = 3, answer = NO)
14 Correct 2 ms 720 KB OK (n = 3, answer = YES)
15 Correct 2 ms 720 KB OK (n = 3, answer = YES)
16 Correct 2 ms 720 KB OK (n = 3, answer = NO)
17 Correct 2 ms 752 KB OK (n = 3, answer = NO)
18 Correct 2 ms 752 KB OK (n = 100, answer = NO)
19 Correct 2 ms 752 KB OK (n = 100, answer = YES)
20 Incorrect 2 ms 752 KB sum of weights should be in [302..304] but it is 300
21 Halted 0 ms 0 KB -