제출 #1225505

#제출 시각아이디문제언어결과실행 시간메모리
1225505_rain_Long Distance Coach (JOI17_coach)C++20
0 / 100
0 ms320 KiB
#include<bits/stdc++.h> using namespace std; typedef long long LL; const int N=(int)2e5; const LL INF=(LL)1e18; int s[N+2]; pair<int,int>d[N+2]; int n,m; LL w,x,t; namespace subtask1{ bool check(){ return n<=1000 && m<=1000; } LL pre[N+2]={}; int need[N+2]={}; LL dp[N+2]={}; void main_code(){ sort(s+1,s+n+1); sort(d+1,d+m+1,[&](pair<int,int> x,pair<int,int> y){ return x.first % t < y.first % t; }); for(int i=1;i<=m;++i) pre[i]=pre[i-1]+d[i].second; for(int i=1;i<=n;++i) { int pos=upper_bound(d+1,d+m+1,pair<int,int>(s[i]%t,-1))-d-1; if (need[pos]==0) need[pos]=i; } dp[0]=(LL)(x/t)*w+w; for(int i=1;i<=m;++i){ dp[i]=dp[i-1]+(LL)(x/t+(x%t>=d[i].first))*w; if (need[i]){ for(int j=0;j<i;++j){ dp[i]=min(dp[i],dp[j]+pre[i]-pre[j]+(LL)(s[need[i]]/t)*(i-j)*w); } } } cout<<dp[m]<<'\n'; } } int main(){ ios::sync_with_stdio(false); cin.tie(0) ; cout.tie(0); #define task "main" if (fopen(task".inp","r")){ freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } cin>>x>>n>>m>>w>>t; for(int i=1;i<=n;++i) cin>>s[i]; for(int i=1;i<=m;++i) cin>>d[i].first>>d[i].second; return subtask1::main_code(),0; return 0; }

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

coach.cpp: In function 'int main()':
coach.cpp:50:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |                 freopen(task".inp","r",stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
coach.cpp:51:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |                 freopen(task".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...