답안 #751428

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
751428 2023-05-31T14:42:54 Z tolbi 비스킷 담기 (IOI20_biscuits) C++17
12 / 100
1 ms 340 KB
#pragma optimize("Bismillahirrahmanirrahim")
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█■█
//█─█─█▄─█▄─█─█─█─█
//Allahuekber
//ahmet23 orz...
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//YavuzSultanSelimHan
//AbdulhamidHan
#define author tolbi
#include <bits/stdc++.h>
using namespace std;
template<typename X, typename Y> istream& operator>>(istream& in, pair<X,Y> &pr) {return in>>pr.first>>pr.second;}
template<typename X, typename Y> ostream& operator<<(ostream& os, pair<X,Y> pr) {return os<<pr.first<<" "<<pr.second;}
template<typename X> istream& operator>>(istream& in, vector<X> &arr) {for(auto &it : arr) in>>it; return in;}
template<typename X> ostream& operator<<(ostream& os, vector<X> arr) {for(auto &it : arr) os<<it<<" "; return os;}
template<typename X, size_t Y> istream& operator>>(istream& in, array<X,Y> &arr) {for(auto &it : arr) in>>it; return in;}
template<typename X, size_t Y> ostream& operator<<(ostream& os, array<X,Y> arr) {for(auto &it : arr) os<<it<<" "; return os;}
#define int long long
#define endl '\n'
#define vint(x) vector<int> x
#define deci(x) int x;cin>>x;
#define decstr(x) string x;cin>>x;
#define cinarr(x) for (auto &it : x) cin>>it;
#define coutarr(x) for (auto &it : x) cout<<it<<" ";cout<<endl;
#define sortarr(x) sort(x.begin(),x.end())
#define sortrarr(x) sort(x.rbegin(),x.rend())
#define det(x) cout<<"NO\0YES"+x*3<<endl;
#define INF LONG_LONG_MAX
#define rev(x) reverse(x.begin(),x.end());
#define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define tol(bi) (1LL<<((int)(bi)))
const int MOD = 1e9+7;
mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count());
#ifdef tolbi
#else
#include "biscuits.h"
#endif




long long count_tastiness(long long x, vector<long long> arr) {
	int n = arr.size();
	vector<int> bosl(n);
	int somma = 0;
	int crr = 0;
	int ca = 0;
	for (int i = 0; i < n; i++){
		int kal = arr[i];
		while (kal){
			while (ca<n && somma+tol(i)>=tol(ca)){
				if (ca<=i){
					bosl[ca]=crr+(tol(ca)-somma-1);
					if (!arr[ca]) bosl[ca]++;
				}
				else {
					bosl[ca]=bosl[ca-1]*2;
				}
				ca++;
			}
			if (ca<n && somma+kal*tol(i)>=tol(ca)){
				int ara = (tol(ca)-somma)/tol(i);
				while (ara*tol(i)+somma<tol(ca)) ara++;
				while (ara*tol(i)+somma>=tol(ca)) ara--;
				kal-=ara;
				crr+=bosl[i]*ara;
				somma+=tol(i)*ara;
			}
			else {
				somma+=kal*tol(i);
				crr+=kal*bosl[i];
				kal=0;
			}
		}
	}
	return somma-crr+1;
}

#ifdef tolbi
int32_t main() {
	int32_t q;
	assert(scanf("%d", &q) == 1);
	vector<int32_t> k(q);
	vector<long long> x(q);
	vector<vector<long long>> a(q);
	vector<long long> results(q);
	for (int32_t t = 0; t < q; t++) {
		assert(scanf("%d%lld", &k[t], &x[t]) == 2);
		a[t] = vector<long long>(k[t]);
		for (int32_t i = 0; i < k[t]; i++) {
			assert(scanf("%lld", &a[t][i]) == 1);
		}
	}
	fclose(stdin);

	for (int32_t t = 0; t < q; t++) {
		results[t] = count_tastiness(x[t], a[t]);
	}
	for (int32_t t = 0; t < q; t++) {
		printf("%lld\n", results[t]);
	}
	fclose(stdout);
	return 0;
}
#endif

Compilation message

biscuits.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    1 | #pragma optimize("Bismillahirrahmanirrahim")
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 308 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 224 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 308 KB Output isn't correct
3 Halted 0 ms 0 KB -