이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC optimize("conserve-stack")
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define NHP ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms";
using namespace std;
#define getchar_unlocked getchar
inline int scan()
{
char c = getchar_unlocked();
int x = 0;
while (c < '0' || c > '9')
{
c = getchar_unlocked();
}
while (c >= '0' && c <= '9')
{
x = (x << 1) + (x << 3) + c - '0';
c = getchar_unlocked();
}
return x;
}
void phongbeo();
const int inf = 1e9;
const int mod2 = 1e9 + 7;
const int mod1 = 998244353;
struct icd
{
long double a;
int b;
};
struct ib
{
int a;
int b;
};
struct ic
{
int a, b, c;
};
struct id
{
int a, b, c, d;
};
struct ie
{
int a, b, c, d, e;
};
int n, m, s1, s2, s4, s3, sf, k, s5, s6, mx, s7, s8, s9, mx2, res, dem2 = 0, dem = 0, s33, dem3, dem4, mid, l2, r2, center;
int i, s10, s12,k1,k2,k3,s11,limit,w,l,r,last,root;
int kk;
int el = 19;
main()
{
if(fopen(task".inp","r"))
{
fin(task);
fou(task);
}
NHP
/// cin>>s1;
///modwwe
phongbeo();
// checktime
}
struct seg
{
int a,b;
int cnt;
int mx;
void init(int x)
{
cnt=1;
a=-x;
b=k-x;
}
}
t[800101];
int a[201000];
vector<pair<int,int>>v;
seg mer(seg a,seg b)
{
seg c;
c.a=min(b.a,a.a-k*b.cnt);
c.b=max(b.b+a.cnt*k,a.b);
c.cnt=a.cnt+b.cnt;
c.mx=max({a.mx,b.mx,b.b-a.a});
return c;
}
void upd(int node,int l,int r,int l1)
{
if(l==r)
{
t[node].init(v[l-1].first);
return;
}
int mid=l+r>>1;
if(l1<=mid) upd(node<<1,l,mid,l1);
else upd(node<<1|1,mid+1,r,l1);
t[node]=mer(t[node<<1],t[node<<1|1]);
}
void upd(int x)
{
upd(1,1,n,x);
if(v[x-1].second>mx)
{
cout<<t[1].mx/2;
if(t[1].mx%2==1)cout<<".5";
cout<<" ";
}
}
void phongbeo()
{
cin>>n>>m>>k;
mx=n;
n+=m;
for(int i=1; i<=n; i++)
{
cin>>a[i];
v.pb({a[i],i});
}
sort(v.begin(),v.end());
for(int i=1; i<=n; i++)
a[i]=lower_bound(v.begin(),v.end(),make_pair(a[i],i))-v.begin()+1;
for(int i=1;i<=n*4;i++)
t[i].a=inf,t[i].mx=0,t[i].b=-inf,t[i].cnt=0;
for(int i=1; i<=n; i++)
{
upd(a[i]);
}
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp:69:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
69 | main()
| ^~~~
Main.cpp: In function 'void upd(long long int, long long int, long long int, long long int)':
Main.cpp:113:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
113 | int mid=l+r>>1;
| ~^~
Main.cpp:115:5: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
115 | else upd(node<<1|1,mid+1,r,l1);
| ^~~~
Main.cpp:116:10: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
116 | t[node]=mer(t[node<<1],t[node<<1|1]);
| ^
Main.cpp: In function 'void phongbeo()':
Main.cpp:143:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
143 | for(int i=1;i<=n*4;i++)
| ^~~
Main.cpp:145:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
145 | for(int i=1; i<=n; i++)
| ^~~
Main.cpp: In function 'int main()':
Main.cpp:13:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
13 | #define fin(x) freopen(x".inp","r",stdin)
| ~~~~~~~^~~~~~~~~~~~~~~~~~~
Main.cpp:73:9: note: in expansion of macro 'fin'
73 | fin(task);
| ^~~
Main.cpp:14:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
14 | #define fou(x) freopen(x".out","w",stdout)
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:74:9: note: in expansion of macro 'fou'
74 | fou(task);
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |