답안 #237046

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
237046 2020-06-04T10:19:07 Z michao Detecting Molecules (IOI16_molecules) C++14
0 / 100
5 ms 384 KB
#include <bits/stdc++.h>
#include "molecules.h"
#define ll long long int
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

vi find_subset(int l,int u,vi w)
{
	vector<pii>tab;
	int n=sz(w);
	tab.clear();
	int licznik=1;
	for (auto it:w)tab.pb(mp(it,licznik)),licznik++;
	sort(tab.begin(),tab.end());
	vi ans;
	ans.clear();
	int wskl=-1,wskr=-1;
  vector<ll> pref;
  pref.clear();
  ll sum=0;
  for (int i=0;i<n;i++)sum+=tab[i].st,pref.pb(sum);
  for (int i=0;i<sz(pref);i++)
  {
  	if (pref[i]>=l && pref[i]<=u)
  	{
  		wskl=0,wskr=i;
  		break;
  	}
  	else if (pref[i]>u)
  	{
  		int ile=pref[i]-u;
  		int wsk=*lower_bound(pref.begin(),pref.end(),ile);
  		if (pref[i]-wsk>=l && pref[i]-wsk<=u)
  		{
  			int wsk2=lower_bound(pref.begin(),pref.end(),ile)-pref.begin();
  			wskl=wsk2+1,wskr=i;
  			if (wskl>wskr)wskl=-1,wskr=-1;
  			else break;
  		}
  	}
  }
  if (wskl!=-1)for (int i=wskl;i<=wskr;i++)ans.pb(tab[i].nd);
	return ans;
}
/*
int32_t main()
{
  BOOST;
  vi rak;
  rak=find_subset(10, 20, {15, 17, 16, 18});
  cout<<sz(rak)<<"\n";
  for (auto it:rak)cout<<it<<" ";
  return 0;
}
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB OK (n = 1, answer = NO)
2 Correct 5 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 4 ms 256 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB OK (n = 12, answer = YES)
2 Correct 5 ms 384 KB OK (n = 12, answer = YES)
3 Correct 4 ms 256 KB OK (n = 12, answer = NO)
4 Correct 4 ms 256 KB OK (n = 12, answer = NO)
5 Incorrect 4 ms 256 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 5 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 4 ms 256 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB OK (n = 1, answer = NO)
2 Correct 5 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 4 ms 256 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB OK (n = 1, answer = NO)
2 Correct 5 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 4 ms 256 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB OK (n = 1, answer = NO)
2 Correct 5 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 4 ms 256 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -