제출 #1085650

#제출 시각아이디문제언어결과실행 시간메모리
1085650DJeniUpCloud Computing (CEOI18_clo)C++17
100 / 100
861 ms2168 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll,ll>pairll; typedef pair<ll,ull>pairull; typedef pair<ll,pairll>pair3l; typedef long double ld; typedef pair<ld,ld>pairld; typedef pair<string,ll>pairsl; #define fr first #define sc second #define pb push_back #define endl '\n' #define N 100007 #define MOD 1000000007 #define INF 10000000000007 #define eps 0.00000000001 #define A 50 #define PI 3.14159265359 int n,m; ll dp[2][2002][A+2]; struct D{ int c,f,v; }d[2007],t[2007]; inline bool mcp(D d1, D d2){ return d1.f<d2.f; } int main(){ ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); scanf("%ld", &m); for(int i=1;i<=m;i++){ //cin>>t[i].c>>t[i].f>>t[i].v; scanf("%ld %ld %ld", &t[i].c, &t[i].f, &t[i].v); } sort(t+1,t+1+m,mcp); //cin>>n; scanf("%ld", &n); for(int i=1;i<=n;i++){ //cin>>d[i].c>>d[i].f>>d[i].v; scanf("%ld %ld %ld", &d[i].c, &d[i].f, &d[i].v); } sort(d+1,d+1+n,mcp); for(int i=0;i<2;i++){ for(int j=1;j<=m+1;j++){ for(int k=1;k<=A+1;k++){ dp[i][j][k]=-INF; } } } d[n+1].f=d[n].f; for(int i1=n+1;i1>=1;i1--){ swap(dp[0],dp[1]); ll i=0; for(int j=m;j>=1;j--){ dp[0][j][max(d[i1].c,max(d[i1-1].c,t[j].c))+1]=-INF; for(int k=max(d[i1].c,max(d[i1-1].c,t[j].c));k>=0;k--){ // cout<<i<<" "<<j<<" "<<k<<endl; dp[i][j][k]=max(dp[i+1][j][k],max(dp[i][j+1][k],dp[i][j][k+1])); if(t[j].f>=d[i1].f && k+d[i1].c-t[j].c>=0 && k+d[i1].c-t[j].c<=A)dp[i][j][k]=max(dp[i][j][k],dp[i+1][j+1][k+d[i1].c-t[j].c]+d[i1].v-t[j].v); if(t[j].f>=d[i1-1].f && k-t[j].c>=0)dp[i][j][k]=max(dp[i][j+1][k-t[j].c]-t[j].v,dp[i][j][k]); if(k+d[i1].c<=A)dp[i][j][k]=max(dp[i][j][k],dp[i+1][j][k+d[i1].c]+d[i1].v); //if(k<=30)cout<<i<<" "<<j<<" "<<k<<" "<<dp[i][j][k]<<endl; } } } cout<<dp[0][1][0]<<endl; return 0; }

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

clo.cpp: In function 'int main()':
clo.cpp:46:14: warning: format '%ld' expects argument of type 'long int*', but argument 2 has type 'int*' [-Wformat=]
   46 |     scanf("%ld", &m);
      |            ~~^   ~~
      |              |   |
      |              |   int*
      |              long int*
      |            %d
clo.cpp:49:18: warning: format '%ld' expects argument of type 'long int*', but argument 2 has type 'int*' [-Wformat=]
   49 |         scanf("%ld %ld %ld", &t[i].c, &t[i].f, &t[i].v);
      |                ~~^           ~~~~~~~
      |                  |           |
      |                  long int*   int*
      |                %d
clo.cpp:49:22: warning: format '%ld' expects argument of type 'long int*', but argument 3 has type 'int*' [-Wformat=]
   49 |         scanf("%ld %ld %ld", &t[i].c, &t[i].f, &t[i].v);
      |                    ~~^                ~~~~~~~
      |                      |                |
      |                      long int*        int*
      |                    %d
clo.cpp:49:26: warning: format '%ld' expects argument of type 'long int*', but argument 4 has type 'int*' [-Wformat=]
   49 |         scanf("%ld %ld %ld", &t[i].c, &t[i].f, &t[i].v);
      |                        ~~^                     ~~~~~~~
      |                          |                     |
      |                          long int*             int*
      |                        %d
clo.cpp:53:14: warning: format '%ld' expects argument of type 'long int*', but argument 2 has type 'int*' [-Wformat=]
   53 |     scanf("%ld", &n);
      |            ~~^   ~~
      |              |   |
      |              |   int*
      |              long int*
      |            %d
clo.cpp:56:18: warning: format '%ld' expects argument of type 'long int*', but argument 2 has type 'int*' [-Wformat=]
   56 |         scanf("%ld %ld %ld", &d[i].c, &d[i].f, &d[i].v);
      |                ~~^           ~~~~~~~
      |                  |           |
      |                  long int*   int*
      |                %d
clo.cpp:56:22: warning: format '%ld' expects argument of type 'long int*', but argument 3 has type 'int*' [-Wformat=]
   56 |         scanf("%ld %ld %ld", &d[i].c, &d[i].f, &d[i].v);
      |                    ~~^                ~~~~~~~
      |                      |                |
      |                      long int*        int*
      |                    %d
clo.cpp:56:26: warning: format '%ld' expects argument of type 'long int*', but argument 4 has type 'int*' [-Wformat=]
   56 |         scanf("%ld %ld %ld", &d[i].c, &d[i].f, &d[i].v);
      |                        ~~^                     ~~~~~~~
      |                          |                     |
      |                          long int*             int*
      |                        %d
clo.cpp:46:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |     scanf("%ld", &m);
      |     ~~~~~^~~~~~~~~~~
clo.cpp:49:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |         scanf("%ld %ld %ld", &t[i].c, &t[i].f, &t[i].v);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:53:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |     scanf("%ld", &n);
      |     ~~~~~^~~~~~~~~~~
clo.cpp:56:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |         scanf("%ld %ld %ld", &d[i].c, &d[i].f, &d[i].v);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...