Submission #951231

#TimeUsernameProblemLanguageResultExecution timeMemory
951231NourWaelFuel Station (NOI20_fuelstation)C++17
0 / 100
966 ms1048576 KiB
#include <bits/stdc++.h> #define int long long using namespace std; int const mxN = 3e5+5; vector<pair<int,pair<int,int>>>a; vector<int> pos; int n,d; void solve (int i, int sum) { if(i==n+1) { pos.push_back(sum); return; } solve(i+1,sum); solve(i+1, d-(sum+a[i].first+a[i].second.first)); solve(i+1, sum+a[i].first); } signed main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin>>n>>d; a.resize(n+1); for(int i=0; i<n; i++) cin>>a[i].first>>a[i].second.first>>a[i].second.second; a[n] = {d,{0,0}}; sort(a.begin(),a.end()); solve(0,0); sort(pos.begin(),pos.end()); for(int i=0; i<pos.size(); i++) { int mid = pos[i], now = pos[i]; bool f = 1; if(mid<a[0].first) f = 0; else now -= a[0].first; for(int j=0; j<n; j++) { if(mid<=a[j].second.second) now += a[j].second.first; if(now<abs(a[j+1].first-a[j].first)) { f = 0; break; } now -= abs(a[j+1].first-a[j].first); } if(f) { cout<<mid<<'\n'; return 0; } } return 0; }

Compilation message (stderr)

FuelStation.cpp: In function 'int main()':
FuelStation.cpp:30:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   for(int i=0; i<pos.size(); i++) {
      |                ~^~~~~~~~~~~
#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...