이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define endl '\n'
#define INF 1e9+7
#define all(x) x.begin(),x.end()
using namespace std;
using namespace __gnu_pbds;
using ll=long long;
using pii=pair<int,int>;
using ppi=pair<int,pii>;
using oset=tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;
template<typename T>
void _print(vector<T> x) {for(auto e:x) cerr<<e<<",";}
template<typename T>
void _print(T x) {cerr<<x;}
void dbg() {cerr<<endl;}
template<typename Head,typename... Tail>
void dbg(Head H,Tail... T) {
_print(H);
if(sizeof...(T)) cerr<<",";
else cerr<<"\"]";
dbg(T...);
}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:[\"",dbg(__VA_ARGS__)
int n;
vector<pii> a;
vector<int> b;
int main () {
ios::sync_with_stdio(false); cin.tie(0);
cin>>n; a.resize(n+1); b.resize(n);
for(int i=0;i<=n;i++) {
cin>>a[i].first; a[i].second=i;
}
vector<int> idx(n+1);
sort(all(a));
for(int i=0;i<=n;i++) idx[a[i].second]=i;
for(int i=0;i<n;i++) cin>>b[i]; sort(all(b));
vector<int> dif(n),dif1(n);
for(int i=0;i<n;i++) {
dif[i]=max(a[i].first-b[i],0);
dif1[i]=max(a[i+1].first-b[i],0);
}
for(int i=1;i<n;i++) {
dif[i]=max(dif[i],dif[i-1]);
}
for(int i=n-2;i>=0;i--) {
dif1[i]=max(dif1[i],dif1[i+1]);
}
for(int i=0;i<=n;i++) {
int j=idx[i];
if(j==n) cout<<dif[n-1]<<' ';
else {
int res=dif1[j];
if(j) res=max(res,dif[j-1]);
cout<<res<<' ';
}
}
cout<<endl;
}
컴파일 시 표준 에러 (stderr) 메시지
ho_t1.cpp: In function 'int main()':
ho_t1.cpp:42:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
42 | for(int i=0;i<n;i++) cin>>b[i]; sort(all(b));
| ^~~
ho_t1.cpp:42:37: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
42 | for(int i=0;i<n;i++) cin>>b[i]; sort(all(b));
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |