제출 #1285946

#제출 시각아이디문제언어결과실행 시간메모리
1285946hainam2k9Treatment Project (JOI20_treatment)C++20
35 / 100
3090 ms2580 KiB
#include <bits/stdc++.h> #define tt cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(0) #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout) #define ll long long #define ull unsigned long long #define i128 __int128 #define db long double #define sz(a) ((int)(a).size()) #define pb emplace_back #define pf emplace_front #define pob pop_back #define pof pop_front #define lb lower_bound #define ub upper_bound #define fi first #define se second #define ins emplace #define mp make_pair using namespace std; const int MOD = 1e9+7, MAXN = 1e5+5; const string NAME = ""; struct Project{ int t,l,r,cost; }a[MAXN]; int n,m; ll dp[MAXN],rs=1e18; priority_queue<pair<ll,int>, vector<pair<ll,int>>, greater<pair<ll,int>>> pq; bool check(int i, int j){ if(a[i].t>=a[j].t) return a[i].r+1>=a[j].l+a[i].t-a[j].t; return a[i].r+a[i].t-a[j].t+1>=a[j].l; } int main() { tt; if(fopen((NAME + ".INP").c_str(), "r")) fo; memset(dp,0x3f,sizeof(dp)); cin >> n >> m; for(int i = 1; i<=m; ++i){ cin >> a[i].t >> a[i].l >> a[i].r >> a[i].cost; if(a[i].l==1) dp[i]=a[i].cost, pq.ins(a[i].cost,i); } while(!pq.empty()){ pair<ll,int> top=pq.top(); pq.pop(); if(top.fi>dp[top.se]) continue; if(a[top.se].r==n) rs=min(rs,top.fi); for(int i = 1; i<=m; ++i) if(check(top.se,i)&&dp[i]>top.fi+a[i].cost) dp[i]=top.fi+a[i].cost, pq.ins(dp[i],i); } cout << (rs>=1e18 ? -1 : rs); }

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

treatment.cpp: In function 'int main()':
treatment.cpp:3:19: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
treatment.cpp:35:45: note: in expansion of macro 'fo'
   35 |     if(fopen((NAME + ".INP").c_str(), "r")) fo;
      |                                             ^~
treatment.cpp:3:63: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
      |                                                        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
treatment.cpp:35:45: note: in expansion of macro 'fo'
   35 |     if(fopen((NAME + ".INP").c_str(), "r")) fo;
      |                                             ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...