제출 #1311758

#제출 시각아이디문제언어결과실행 시간메모리
1311758chithanhnguyenFuel Station (NOI20_fuelstation)C++20
100 / 100
104 ms7240 KiB
// .=*#= // .=*=+* -#: // -*+. += .#= // -*= *- .#= // :*= *#++#* .%: // ++. *- =+ -# // :*- *- *= %- // .------::. -*. += -+++-. *# // -*:-=+*#%#*++-. =+ -+ :+*- +@. // :* .-++-:=++: ++ .# .*: +%- // .# .:+#- .=*=. =+ *: :++. *+= // % -%*=-=*. :*+. -* :* :++=. #-+ // #: .=*- .*: :*= .:==++++* +- -**+: :*:+ // += -#: *- :*- :=++=-:. =*- :+++- *-:+ // -# .=*- *- =*+*=: -*= == .# -#++++++++=-: // @: =*: #: .. -*-# *: == .:-+++: // ** :#: .#. .*@. =+ +: .-*+: // :@: .=++=:. -* +. :# #. .+*: // ## :-*@* +- .#. .# .++=-. // :@+ =#*++-.# *: -+ .-+++- // *%- #+- *. .-*+. // .##- +@ -. .# .++. // :*++ :% .=+. :*:*: :*- // =+-*: - :++. .** =. += // =+.++: .++. #. == += // =+ .=*=. .*: *: *: *: // -*. :++=: .#. #. .-*- .# // :*: .=: *: += .-=+++++==++++=: *: // .*= ... . += -++=:. :+ // -*: .. =++++==++++=: :*+++- # // .++. == . .== .+%*=. % // .*+== =#%= % // :#* .:. -***..::. % // #: +%@@: -*-+%++=--*- .# // .*- :=*= -*- =%- *: -= // =*=. =*- -* # .-. #. // :=#*++++++++++++++++-:::-+*- #. .*+=#. == // *: .*- #----: == %+++++++++: -* // % -*+- .#: #. +- -* // % ##:+**. =*%. -% -+ ++ // *: #:+: :**-+= .## :* :*- // :#=- +-# :*: .#:# :#. :*+. // .*#+*+. :*. .*: % .#*+=: :*+. // #..+ :*: #. .++ :+*- // :**= # :++. == .*+. .:=++=. // :=++*++=. .# .+%+==++++++-. // *: .-+++++=-::.. // :* .=++=:. // +- -*+: // .#..=*- // =#*: // .- #include <bits/stdc++.h> #define prob "" #define int long long using namespace std; void file(){ freopen(prob".INP", "r", stdin); freopen(prob".OUT", "w", stdout); } void Init() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); //file(); } struct c{ int x,f,r; }; bool check(c a,c b){ return a.x<b.x; } void Sol() { int n,h; cin>>n>>h; vector<c>a(n); for(int i=0;i<n;i++){ cin>>a[i].x>>a[i].f>>a[i].r; } sort(a.begin(),a.end(),check); int l=0,r=0,res=-1; for(auto i:a){ r=max(r,i.r); } int temp=a[0].x; for(int i=0;i<n;i++){ if(temp>=a[i].x&&a[0].x<=a[i].r){ temp+=a[i].f; } } if(temp>=h){ res=a[0].x; cout<<res; return; } while(l<=r){ int mid=(l+r)/2; temp=mid; for(int i=0;i<n;i++){ if(temp>=a[i].x&&mid<=a[i].r){ temp+=a[i].f; } } //cout<<mid<<" "<<temp<<"\n"; if(temp>=h){ res=mid; r=mid-1; }else{ l=mid+1; } } cout<<(res==-1?h:res); } signed main(){ Init(); Sol(); return 0; }

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

FuelStation.cpp: In function 'void file()':
FuelStation.cpp:59:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   59 |     freopen(prob".INP", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
FuelStation.cpp:60:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   60 |     freopen(prob".OUT", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...