제출 #228487

#제출 시각아이디문제언어결과실행 시간메모리
228487Ruxandra985Just Long Neckties (JOI20_ho_t1)C++14
100 / 100
161 ms13276 KiB
#include <bits/stdc++.h> #define DIMN 200010 using namespace std; pair <int,int> v[DIMN]; int w[DIMN]; priority_queue <pair <int,int> > h; int val[DIMN] , sol[DIMN]; int main() { FILE *fin = stdin; FILE *fout = stdout; int n , i , x , idx; fscanf (fin,"%d",&n); for (i = 1 ; i <= n + 1 ; i++){ fscanf (fin,"%d",&v[i].first); v[i].second = i; } for (i = 1 ; i <= n ; i++){ fscanf (fin,"%d",&w[i]); } sort (w + 1 , w + n + 1); sort (v + 1 , v + n + 2); /// o sa cuplezi al i lea din w cu al i + 1 lea din v for (i = 1 ; i <= n ; i++){ h.push(make_pair(max(0 , v[i].first - w[i]) , i)); val[i] = max(0 , v[i].first - w[i]); } /// asta ar fi solutia pt cand elimini v[1].second sol[v[n+1].second] = h.top().first; for (i = n ; i ; i--){ val[i] = max(0 , v[i + 1].first - w[i]); h.push(make_pair(val[i] , i)); /// pe v[i + 1].second il stergi x = h.top().first; idx = h.top().second; while (val[idx] != x){ h.pop(); x = h.top().first; idx = h.top().second; } sol[v[i].second] = h.top().first; } for (i = 1 ; i <= n + 1 ; i++) fprintf (fout,"%d " , sol[i] ); return 0; }

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

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:13:12: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     fscanf (fin,"%d",&n);
     ~~~~~~~^~~~~~~~~~~~~
ho_t1.cpp:15:16: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         fscanf (fin,"%d",&v[i].first);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:20:16: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         fscanf (fin,"%d",&w[i]);
         ~~~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...