이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
vector<pair<int, int>> neckties(n+1);
for (int i=0;i<n+1;i++){
cin>>neckties[i].first;
neckties[i].second=i;
}
vector<int> employees(n);
for (int i=0;i<n;i++) cin>>employees[i];
sort(neckties.begin(), neckties.end(), greater<pair<int, int>>());
sort(employees.begin(), employees.end(), greater<int>());
vector<int> pref(n);
pref[0]=max(0, neckties[0].first-employees[0]);
for (int i=1;i<n;i++){
pref[i]=max(pref[i-1], max(0, neckties[i].first-employees[i]));
}
vector<int> suff(n);
suff[n-1]=max(0, neckties[n].first-employees[n-1]);
for (int i=n-2;i>=0;i--){
suff[i]=max(suff[i+1], max(0, neckties[i+1].first-employees[i]));
}
vector<int> out(n+1);
for (int i=0;i<n+1;i++){
int pr=0, sf=0;
if (i>0) pr=pref[i-1];
if (i<n) sf=suff[i];(
out[neckties[i].second]=max(pr, sf));
}
for (int x:out) cout<<x<<" ";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
ho_t1.cpp: In function 'int main()':
ho_t1.cpp:35:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
35 | if (i<n) sf=suff[i];(
| ^~
ho_t1.cpp:35:29: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
35 | if (i<n) sf=suff[i];(
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |