제출 #1151050

#제출 시각아이디문제언어결과실행 시간메모리
1151050nguynJust Long Neckties (JOI20_ho_t1)C++20
100 / 100
59 ms6984 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define F first #define S second #define pb push_back #define pii pair<int,int> const int N = 2e5 + 5; int n; pii a[N]; int b[N]; int pre[N], suf[N]; int res[N]; signed main(){ ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0) ; if (fopen("INP.INP" ,"r")) { freopen("INP.INP" ,"r" , stdin) ; freopen("OUT.OUT" , "w" , stdout) ; } cin >> n; for (int i = 1; i <= n + 1; i++) { cin >> a[i].F; a[i].S = i; } for (int i = 1; i <= n; i++) { cin >> b[i]; } sort(a + 1, a + 2 + n); sort(b + 1, b + 1 + n); for (int i = 1; i <= n; i++) { pre[i] = max(pre[i - 1], a[i].F - b[i]); } for (int i = n; i >= 1; i--) { suf[i] = max(suf[i + 1], a[i + 1].F - b[i]); } for (int i = 1; i <= n + 1; i++) { res[a[i].S] = max(pre[i - 1], suf[i]); } for (int i = 1; i <= n + 1; i++) { cout << res[i] << ' '; } }

컴파일 시 표준 에러 (stderr) 메시지

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen("INP.INP" ,"r" , stdin) ;
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         freopen("OUT.OUT" , "w" , stdout) ;
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...