Submission #754437

# Submission time Handle Problem Language Result Execution time Memory
754437 2023-06-07T18:58:17 Z tolbi Distributing Candies (IOI21_candies) C++17
29 / 100
132 ms 23144 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;}
template<typename T> vector<int32_t> normalize(vector<T> &arr){vector<int> rv;rv.resize(arr.size());for (int i = 0; i < rv.size(); ++i){rv[i]=arr[i];}return rv;}
#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_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)))
#define int long long
const int MOD = 1e9+7;
mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count());
#include "candies.h"
vector<int32_t> distribute_candies(vector<int32_t> c, vector<int32_t> l, vector<int32_t> r, vector<int32_t> v) {
	int n = c.size();
	int q = v.size();
	vector<int> suff(q);
	vector<int> pref(q);
	vector<int> mava(q);
	vector<int> miva(q);
	vector<pair<int,int>> arr(n);
	for (int i = 0; i < n; i++){
		arr[i]={c[i],i};
	}
	sortarr(arr);
	for (int i = 0; i < q; i++){
		pref[i]=suff[i]=v[i];
		if (i) pref[i]+=pref[i-1];
	}
	mava.back()=miva.back()=pref.back();
	for (int i = q-2; i >= 0; i--){
		miva[i]=min(miva[i+1],pref[i]);
		mava[i]=max(mava[i+1],pref[i]);
		suff[i]+=suff[i+1];
	}
	int lel = 0;
	int crq = 0;
	vector<int> rval(n,-23);
	for (int i = n-1; i >= 0; i--){
		int crr = min(lel,arr[i].first);
		int kk = 0;
		if (crq) kk=pref[crq-1];
		while (crq<q && ((crr+(mava[crq]-kk)>=arr[i].first) || (crr+(miva[crq]-kk)<=0))) {
			crr+=v[crq];
			crr=min(crr,arr[i].first);
			crr=max(crr,0ll);
			kk=pref[crq];
			crq++;
		}
		kk=0;
		if (crq<q) kk=suff[crq];
		rval[arr[i].second]=crr+kk;
		lel=crr;
	}
	return normalize(rval);
}

Compilation message

candies.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    1 | #pragma optimize("Bismillahirrahmanirrahim")
      | 
candies.cpp: In instantiation of 'std::vector<int> normalize(std::vector<_Tp>&) [with T = long long int]':
candies.cpp:79:23:   required from here
candies.cpp:20:119: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 | template<typename T> vector<int32_t> normalize(vector<T> &arr){vector<int> rv;rv.resize(arr.size());for (int i = 0; i < rv.size(); ++i){rv[i]=arr[i];}return rv;}
      |                                                                                                                     ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 121 ms 18288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 50 ms 11248 KB Output is correct
4 Correct 62 ms 7408 KB Output is correct
5 Correct 116 ms 18280 KB Output is correct
6 Correct 116 ms 18236 KB Output is correct
7 Correct 121 ms 18228 KB Output is correct
8 Correct 132 ms 21696 KB Output is correct
9 Correct 110 ms 23144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -