답안 #218472

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
218472 2020-04-02T07:56:51 Z Sho10 Detecting Molecules (IOI16_molecules) C++14
0 / 100
5 ms 384 KB
/*
ID: Sho10
LANG: C++
*/
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll sum=0;
vector<pair<ll,ll> >v;
vector<int>ans;
vector<int> find_subset(int l,int u,vector<int>w){
for(ll i=0;i<w.size();i++)
{
    v.pb(mp(w[i],i));
}
sort(v.begin(),v.end());
ll sum=0;
ll lx=0,rr=0;
while(lx<=rr&&rr<v.size()){
    if(sum<l){
        sum=sum+v[rr].f;
            rr++;
        if(sum>=l&&sum<=u){
    break;
    }
    }else if(sum>u){
    sum=sum-v[lx].f;
    lx++;
     if(sum>=l&&sum<=u){
    break;
    }
    }else if(sum>=l&&sum<=u){
    break;
    }
}
if(sum<l||sum>u){
    ans.pb(0);
    return ans;
}
for(ll i=lx;i<rr;i++)
    ans.pb(v[i].s);
    if(ans.size()==0){
        ans.pb(0);
    }
return ans;
}
//int32_t main(){
//CODE_START;




Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:28:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 for(ll i=0;i<w.size();i++)
            ~^~~~~~~~~
molecules.cpp:35:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 while(lx<=rr&&rr<v.size()){
               ~~^~~~~~~~~
molecules.cpp:56:1: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
 for(ll i=lx;i<rr;i++)
 ^~~
molecules.cpp:58:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     if(ans.size()==0){
     ^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB OK (n = 12, answer = YES)
2 Correct 5 ms 256 KB OK (n = 12, answer = YES)
3 Incorrect 5 ms 256 KB sum of weights should be in [307..317] but it is 50
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -