답안 #240228

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
240228 2020-06-18T22:26:00 Z Dremix10 Detecting Molecules (IOI16_molecules) C++17
0 / 100
17 ms 6144 KB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define F first
#define S second
//#define endl '\n'
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define maxp 22
#define EPS (ld)(1e-18)
#define mod (int)(1e9+7)
#define N (int)(1e5+1)

bool dp[101][500001];

vector<int> find_subset(int l, int r, vector<int> arr) {
    int n=arr.size();
    int i,j;



    dp[0][0]=true;
    for(i=1;i<=n;i++)
    for(j=0;j<=500000;j++){
        dp[i][j]|=dp[i-1][j];
        if(j>=arr[i-1])
            dp[i][j]|=dp[i-1][j-arr[i-1]];
    }
    int k;
    for(k=l;k<=r;k++)
    if(dp[n][k]){
        //cout<<n<<" "<<k<<endl;
        vector<int> ans;
        int num=k;
        int row=n;
        while(num>0){

            for(i=row;i>0;i--)
                if(num>=arr[i-1])
            if(dp[i-1][num-arr[i-1]]){
                row=i-1;
                num-=arr[i-1];
                ans.push_back(i);
                break;
            }

        }
        return ans;
    }
    return vector<int>(0);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 768 KB OK (n = 1, answer = NO)
2 Correct 6 ms 896 KB OK (n = 1, answer = NO)
3 Incorrect 6 ms 768 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 6144 KB Integer 12 violates the range [0, 11]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 768 KB OK (n = 1, answer = NO)
2 Correct 6 ms 896 KB OK (n = 1, answer = NO)
3 Incorrect 6 ms 768 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 768 KB OK (n = 1, answer = NO)
2 Correct 6 ms 896 KB OK (n = 1, answer = NO)
3 Incorrect 6 ms 768 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 768 KB OK (n = 1, answer = NO)
2 Correct 6 ms 896 KB OK (n = 1, answer = NO)
3 Incorrect 6 ms 768 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 768 KB OK (n = 1, answer = NO)
2 Correct 6 ms 896 KB OK (n = 1, answer = NO)
3 Incorrect 6 ms 768 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -