답안 #216278

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
216278 2020-03-27T02:16:54 Z HNO2 Detecting Molecules (IOI16_molecules) C++17
0 / 100
5 ms 384 KB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn=2e5+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
//#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int n;
pii a[maxn];

int pre[maxn],suf[maxn];

std::vector<int> find_subset(int l, int u, std::vector<int> w)
{
    n=sz(w);
    for (int i=0;i<n;i++) a[i+1]=mkp(w[i],i);

    sort(a+1,a+n+1);
    for (int i=1;i<=n;i++) pre[i]=pre[i-1]+a[i].F;
    for (int i=n;i>=1;i--) suf[i]=suf[i+1]+a[i].F;
    for (int i=1;i<=n;i++)
    {
        if (min(suf[n-i+1],u)-max(pre[i],l)>=0)
        {
            vector<int> ret;
            int tmp1,tmp2;

            int L=0,R=i*(n-i+1)-1;
            while (R-L>1)
            {
                int M=(L+R)>>1;
                tmp1=M/(n-i+1),tmp2=M%(n-i+1);
                if (pre[i-tmp1-1]+suf[n+1-tmp1]+a[tmp2+(i-tmp1)].F>=l) R=M;
                else L=M;
            }

            tmp1=R/(n-i+1),tmp2=R%(n-i+1);
            for (int j=1;j<=i-tmp1-1;j++) ret.pb(a[j].S);
            ret.pb(a[tmp2+(i-tmp1+1)].S);
            for (int j=n+1-tmp1;j<=n;j++) ret.pb(a[j].S);
            return ret;
        }
    }
    return vector<int> ();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB OK (n = 1, answer = NO)
2 Correct 4 ms 384 KB OK (n = 1, answer = NO)
3 Correct 4 ms 288 KB OK (n = 1, answer = YES)
4 Incorrect 5 ms 384 KB item #1 is taken twice
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB OK (n = 12, answer = YES)
2 Correct 5 ms 384 KB OK (n = 12, answer = YES)
3 Correct 5 ms 384 KB OK (n = 12, answer = NO)
4 Correct 4 ms 384 KB OK (n = 12, answer = NO)
5 Incorrect 4 ms 384 KB sum of weights should be in [290..300] but it is 301
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB OK (n = 1, answer = NO)
2 Correct 4 ms 384 KB OK (n = 1, answer = NO)
3 Correct 4 ms 288 KB OK (n = 1, answer = YES)
4 Incorrect 5 ms 384 KB item #1 is taken twice
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB OK (n = 1, answer = NO)
2 Correct 4 ms 384 KB OK (n = 1, answer = NO)
3 Correct 4 ms 288 KB OK (n = 1, answer = YES)
4 Incorrect 5 ms 384 KB item #1 is taken twice
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB OK (n = 1, answer = NO)
2 Correct 4 ms 384 KB OK (n = 1, answer = NO)
3 Correct 4 ms 288 KB OK (n = 1, answer = YES)
4 Incorrect 5 ms 384 KB item #1 is taken twice
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB OK (n = 1, answer = NO)
2 Correct 4 ms 384 KB OK (n = 1, answer = NO)
3 Correct 4 ms 288 KB OK (n = 1, answer = YES)
4 Incorrect 5 ms 384 KB item #1 is taken twice
5 Halted 0 ms 0 KB -