답안 #289499

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
289499 2020-09-02T17:17:38 Z TadijaSebez 치료 계획 (JOI20_treatment) C++11
0 / 100
3000 ms 2468 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=100050;
const ll inf=9e18;
ll dp[N];
struct project{
	int t,l,r,c;
	project(){}
	project(int a,int b,int d,int e):t(a),l(b),r(d),c(e){}
	bool operator < (project b){return r+t<b.r+b.t;}
}pro[N];
int main(){
	int n,m;
	scanf("%i %i",&n,&m);
	for(int i=1;i<=m;i++)scanf("%i %i %i %i",&pro[i].t,&pro[i].l,&pro[i].r,&pro[i].c);
	sort(pro+1,pro+1+m);
	ll ans=inf;
	for(int i=1;i<=m;i++){
		if(pro[i].l==1)dp[i]=pro[i].c;
		else dp[i]=inf;
		for(int j=1;j<i;j++){
			int delta_t=abs(pro[i].t-pro[j].t);
			if(delta_t>pro[j].r+1-pro[i].l)continue;
			dp[i]=min(dp[i],dp[j]+pro[i].c);
		}
		if(pro[i].r==n)ans=min(ans,dp[i]);
	}
	printf("%lld\n",ans==inf?-1:ans);
	return 0;
}

Compilation message

treatment.cpp: In function 'int main()':
treatment.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |  scanf("%i %i",&n,&m);
      |  ~~~~~^~~~~~~~~~~~~~~
treatment.cpp:16:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |  for(int i=1;i<=m;i++)scanf("%i %i %i %i",&pro[i].t,&pro[i].l,&pro[i].r,&pro[i].c);
      |                       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3086 ms 2468 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 0 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 0 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3086 ms 2468 KB Time limit exceeded
2 Halted 0 ms 0 KB -