제출 #563948

#제출 시각아이디문제언어결과실행 시간메모리
563948dantoh000Two Dishes (JOI19_dishes)C++14
10 / 100
144 ms32308 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int INF = 1000000000000000000; int n,m; int a[200005], s[200005], p[200005]; int b[200005], t[200005], q[200005]; int pa[200005], pp[200005]; int pb[200005], pq[200005]; int mem[2005][2005]; int dp(int i, int j){ if (i == n+1 && j == m+1) return 0; if (mem[i][j] != -1) return mem[i][j]; int T = pa[i-1] + pb[j-1]; int ret = -INF; if (i != n+1){ ret = max(ret, dp(i+1, j) + ((T+a[i] <= s[i])?p[i]:0)); } if (j != m+1){ ret = max(ret, dp(i, j+1) + ((T+b[j] <= t[j])?q[j]:0)); } //printf("%d %d %d %d\n",i,j,T,ret); return mem[i][j] = ret; } main(){ scanf("%lld%lld",&n,&m); for (int i = 1; i <= n; i++){ scanf("%lld%lld%lld",&a[i],&s[i],&p[i]); pa[i] = pa[i-1] + a[i]; pp[i] = pp[i-1] + p[i]; } for (int i = 1; i <= m; i++){ scanf("%lld%lld%lld",&b[i],&t[i],&q[i]); pb[i] = pb[i-1] + b[i]; pq[i] = pq[i-1] + q[i]; } if (n <= 2000 && m <= 2000){ memset(mem,-1,sizeof(mem)); printf("%lld",dp(1,1)); } else{ if (s[1] > t[1]){ swap(n,m); swap(a,b); swap(s,t); swap(p,q); } return 0; } }

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

dishes.cpp:25:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   25 | main(){
      | ^~~~
dishes.cpp: In function 'int main()':
dishes.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     scanf("%lld%lld",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
dishes.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         scanf("%lld%lld%lld",&a[i],&s[i],&p[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dishes.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         scanf("%lld%lld%lld",&b[i],&t[i],&q[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...
#Verdict Execution timeMemoryGrader output
Fetching results...