이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <fstream>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <iterator>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(),x.end()
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll INF=1e18+123;
const ld EPS=1e-9;
const int inf=1e9+123;
const int MOD=1e9+7;
const int N=1e5+123;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};
int s[N];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,m,k;
cin>>n>>m>>k;
ll a,b,c,t;
cin>>a>>b>>c>>t;
for(int i=1;i<=m;i++){
cin>>s[i];
}
k-=m;
ll ans=0;
int lk=-1;
multiset<int>q;
for(int i=2;i<=m;i++){
ll d=(s[i-1]-1)*b;
if(d>t)break;
ans++;
int L=s[i-1];
while(L<s[i]-1){
int l=L+1,r=s[i];
while(l<r){
int mid=(l+r)/2;
if((mid-s[i-1]+0ll)*a+d<=t){
l=mid+1;
}
else r=mid;
}
r--;
if((r-s[i-1]+1)*c+d>t){
L=inf;
break;
}
int x=min((t-((r-s[i-1]+1)*c+d))/a+1,s[i]-r-1ll);
ans+=r-L;
L=r;
if(sz(q)==k){
if(k && *q.begin()<x){
ans-=*q.begin();
q.erase(q.begin());
ans+=x;
L+=x;
q.insert(x);
}
else{
L=inf;
break;
}
}
else{
L+=x;
ans+=x;
q.insert(x);
}
}
}
ans+=((s[m]-1)*b<=t);
cout<<ans-1<<" ";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
semiexpress.cpp: In function 'int main()':
semiexpress.cpp:59:9: warning: unused variable 'lk' [-Wunused-variable]
int lk=-1;
^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |