제출 #833052

#제출 시각아이디문제언어결과실행 시간메모리
833052jaeJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
222 ms18588 KiB
#include <bits/stdc++.h> #define SIZE 200005 using namespace std; typedef pair <int,int> P; int ans[SIZE]; int main() { int n; scanf("%d",&n); vector <int> A; vector <P> B; for(int i=0;i<n+1;i++) { int b; scanf("%d",&b); B.push_back(P(b,i)); } for(int i=0;i<n;i++) { int a; scanf("%d",&a); A.push_back(a); } sort(A.begin(),A.end()); sort(B.begin(),B.end()); multiset <int> st; multiset <int>::iterator it; for(int i=0;i<n;i++) { int d=max(0,B[i+1].first-A[i]); st.insert(d); } for(int i=0;i<=n;i++) { it=st.end();it--; ans[B[i].second]=*it; if(i==n) break; int d=max(0,B[i+1].first-A[i]); it=st.lower_bound(d); st.erase(it); d=max(0,B[i].first-A[i]); st.insert(d); } for(int i=0;i<=n;i++) { if(i!=0) printf(" "); printf("%d",ans[i]); }puts(""); return 0; }

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

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
ho_t1.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   scanf("%d",&b);
      |   ~~~~~^~~~~~~~~
ho_t1.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |   scanf("%d",&a);
      |   ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...