이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <utility>
#include <bitset>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <queue>
#include <cstring>
#include <fstream>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pll pair<ll, ll>
#define plpll pair<ll, pll>
#define pii pair<int, int>
#define f first
#define s second
#define inf 1000000000000000
#define endl '\n'
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll n;
cin >> n;
ll b[n];
pll a[n+1];
for(int i=0;i<n+1;i++) cin >> a[i].f, a[i].s=i;
sort(a, a+n+1);
for(int i=0;i<n;i++) cin >> b[i];
sort(b, b+n);
ll mx[n];
mx[n-1]=max(0ll, a[n].f-b[n-1]);
for(int i=n-2;i>=0;i--){
mx[i]=max(mx[i+1], a[i+1].f-b[i]);
}
ll ans[n+1], cool=0;
for(int i=0;i<n;i++){
ans[a[i].s]=max(cool, mx[i]);
cool=max(cool, a[i].f-b[i]);
}
ans[a[n].s]=cool;
for(int i=0;i<n+1;i++) cout << ans[i] << ' ';cout << endl;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
ho_t1.cpp: In function 'int main()':
ho_t1.cpp:47:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
47 | for(int i=0;i<n+1;i++) cout << ans[i] << ' ';cout << endl;
| ^~~
ho_t1.cpp:47:50: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
47 | for(int i=0;i<n+1;i++) cout << ans[i] << ' ';cout << endl;
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |