답안 #196928

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
196928 2020-01-17T18:15:39 Z Swan Detecting Molecules (IOI16_molecules) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
#include "molecules.h"
#define stop system("pause")
#define stop2 char o; cin >> o
#define INP freopen("cowrect.in","r",stdin)
#define OUTP freopen ("cowrect.out","w",stdout)
using namespace std;



vector<int> find_subset(int l, int u, vector<int> w) {
    return {};
    vector<pair<int,int> > start;
    for(int i(0); i < w.size();i++){
        start.push_back({w[i],i});
    }
    sort(start.begin(),start.end());
    sort(w.begin(),w.end());
    if(w[0] > u)return {};
    long long res = 0;
    for(int i(0); i < w.size();i++){
        res+=w[i];
    }
    if(res < l)return {};
    if(res>=l && res<=u){
        return w;
    }
    res = 0;
    set<pair<int,int> > s;
    int cnt = 0;
    int pnt = 0;
    for(int i(0); i < w.size();i++){
        if(res + w[i] > u)break;
        res+=w[i];
        cnt++;
        s.insert({w[i],i});
        pnt++;
    }
    //cout << res << ' ' << cnt << endl;
    vector<int> v;
    while(cnt){
        int now = s.begin()->first;
        res-=now;
        res+=w[pnt];
        s.erase(s.begin());
        s.insert({w[pnt],pnt});
        pnt++;
        cnt--;
        //cout << res << ' ' << l << ' ' << u << endl;
        if(res>=l && res <=u){
            int pnt = 0;
            for(auto& a: s)v.push_back(start[a.second].second);
            return v;
        }
        if(pnt == w.size())break;
    }
    //cout << res << endl;
    return {};
}

/*
main(){
    ios_base::sync_with_stdio(0);
    int l,u,n; cin >> l >> u >> n;
    vector<int> v;
    for(int i(0); i < n;i++){
        int x; cin >> x;
        v.push_back(x);
    }
    vector<int> ans = find_subset(l,u,v);
    for(int i(0); i < ans.size();i++)cout << ans[i] << ' ';
    return 0;
}
*/
/*
15 17 4
6 8 8 7
14 15 4
5 5 6 6
10 20 4
15 17 16 18
0 0 5
10 10 10 10 10
*/

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:14:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i(0); i < w.size();i++){
                   ~~^~~~~~~~~~
molecules.cpp:21:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i(0); i < w.size();i++){
                   ~~^~~~~~~~~~
molecules.cpp:32:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i(0); i < w.size();i++){
                   ~~^~~~~~~~~~
molecules.cpp:51:17: warning: unused variable 'pnt' [-Wunused-variable]
             int pnt = 0;
                 ^~~
molecules.cpp:55:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(pnt == w.size())break;
            ~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB OK (n = 1, answer = NO)
2 Correct 2 ms 256 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 Incorrect 2 ms 252 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB OK (n = 1, answer = NO)
2 Correct 2 ms 256 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 = 1, answer = NO)
2 Correct 2 ms 256 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 = 1, answer = NO)
2 Correct 2 ms 256 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 = 1, answer = NO)
2 Correct 2 ms 256 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 -