답안 #229427

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
229427 2020-05-04T13:02:29 Z nickmet2004 Detecting Molecules (IOI16_molecules) C++11
0 / 100
5 ms 384 KB
#include<bits/stdc++.h>
#include<molecules.h>

#define ll long long

using namespace std;

const int N = 2e5 + 500;
long long pr[N];
vector<int > res;
vector<int> find_subset(int l , int u , vector<int> w){
    int n = w.size();
    pr[0] = w[0];
    for(int i = 1; i < n; ++i){
        pr[i] = pr[i - 1] + w[i];
    }
    for(int i = 0; i < n; ++i) cerr << pr[i] << " "; cerr << endl;
    for(int i = 0; i < n; ++i){
        ll x = pr[i] - l;
        if(x < 0) continue;
        cerr << x << " x " << endl;
        int lw = 0 , rh = i;
        ll ans = -1;
        while(lw <= rh){
            int m =(lw + rh) >> 1;
            if(w[m] <= x){
                ans = m;
                cerr << ans << " ansmid " << endl;
                lw = m + 1;
            } else {
                rh = m - 1;
            }
        }
        if(ans != -1){
            if(pr[i] - w[ans] >= l && pr[i] - w[ans] <= u){
                for(int k = ans + 1; k <= i; ++k){
                    res.emplace_back(w[k]);
                }return res;
            }
        }
    }
    return res;
}
/*
int main (){
    int n, l , u;
    cin >> n >> l >> u;
    vector<int> w (n);
    for(int i = 0; i < n; ++i) cin >> w[i];
    vector<int> ans = find_subset(l , u ,w);
    for(int x : ans) cout << x << " "; cout << endl;
}
*/

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:17:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for(int i = 0; i < n; ++i) cerr << pr[i] << " "; cerr << endl;
     ^~~
molecules.cpp:17:54: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     for(int i = 0; i < n; ++i) cerr << pr[i] << " "; cerr << endl;
                                                      ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 4 ms 384 KB OK (n = 1, answer = NO)
3 Incorrect 5 ms 384 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 4 ms 384 KB OK (n = 1, answer = NO)
3 Incorrect 5 ms 384 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 4 ms 384 KB OK (n = 1, answer = NO)
3 Incorrect 5 ms 384 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 4 ms 384 KB OK (n = 1, answer = NO)
3 Incorrect 5 ms 384 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 4 ms 384 KB OK (n = 1, answer = NO)
3 Incorrect 5 ms 384 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -