답안 #954419

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
954419 2024-03-27T20:46:45 Z amirhoseinfar1385 Intercastellar (JOI22_ho_t1) C++17
0 / 100
263 ms 8876 KB
#include<bits/stdc++.h>
using namespace std;
const long long maxn=200000+10;
long long n;
long long all[maxn];
vector<long long>alls,allv;

void vorod(){
	cin>>n;
	for(long long i=1;i<=n;i++){
		cin>>all[i];
	}
}

void pre(){
	alls.resize(n+2);
	allv.resize(n+2);
	for(long long i=1;i<=n;i++){
		allv[i]=all[i];
		while((allv[i]&1)==0){
			allv[i]>>=1;
		}
		alls[i+1]=alls[i]+all[i]/allv[i];
	}
}

void solve(){
	long long q;
	cin>>q;
	for(long long i=0;i<q;i++){
		long long x;
		cin>>x;
		long long p=lower_bound(alls.begin(),alls.end(),x)-alls.begin();
		p--;
		cout<<allv[p]<<"\n";
	}
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	freopen("inp.txt","r",stdin);
	vorod();
	pre();
	solve();
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:43:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |  freopen("inp.txt","r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 250 ms 8788 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 263 ms 8876 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 250 ms 8788 KB Output isn't correct
2 Halted 0 ms 0 KB -