Submission #1085661

# Submission time Handle Problem Language Result Execution time Memory
1085661 2024-09-08T14:30:03 Z DJeniUp Cloud Computing (CEOI18_clo) C++17
100 / 100
835 ms 2204 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")


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;
}

signed 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;
}

Compilation message

clo.cpp: In function 'int main()':
clo.cpp:47:14: warning: format '%ld' expects argument of type 'long int*', but argument 2 has type 'int*' [-Wformat=]
   47 |     scanf("%ld", &m);
      |            ~~^   ~~
      |              |   |
      |              |   int*
      |              long int*
      |            %d
clo.cpp:50:18: warning: format '%ld' expects argument of type 'long int*', but argument 2 has type 'int*' [-Wformat=]
   50 |         scanf("%ld %ld %ld", &t[i].c, &t[i].f, &t[i].v);
      |                ~~^           ~~~~~~~
      |                  |           |
      |                  long int*   int*
      |                %d
clo.cpp:50:22: warning: format '%ld' expects argument of type 'long int*', but argument 3 has type 'int*' [-Wformat=]
   50 |         scanf("%ld %ld %ld", &t[i].c, &t[i].f, &t[i].v);
      |                    ~~^                ~~~~~~~
      |                      |                |
      |                      long int*        int*
      |                    %d
clo.cpp:50:26: warning: format '%ld' expects argument of type 'long int*', but argument 4 has type 'int*' [-Wformat=]
   50 |         scanf("%ld %ld %ld", &t[i].c, &t[i].f, &t[i].v);
      |                        ~~^                     ~~~~~~~
      |                          |                     |
      |                          long int*             int*
      |                        %d
clo.cpp:54:14: warning: format '%ld' expects argument of type 'long int*', but argument 2 has type 'int*' [-Wformat=]
   54 |     scanf("%ld", &n);
      |            ~~^   ~~
      |              |   |
      |              |   int*
      |              long int*
      |            %d
clo.cpp:57:18: warning: format '%ld' expects argument of type 'long int*', but argument 2 has type 'int*' [-Wformat=]
   57 |         scanf("%ld %ld %ld", &d[i].c, &d[i].f, &d[i].v);
      |                ~~^           ~~~~~~~
      |                  |           |
      |                  long int*   int*
      |                %d
clo.cpp:57:22: warning: format '%ld' expects argument of type 'long int*', but argument 3 has type 'int*' [-Wformat=]
   57 |         scanf("%ld %ld %ld", &d[i].c, &d[i].f, &d[i].v);
      |                    ~~^                ~~~~~~~
      |                      |                |
      |                      long int*        int*
      |                    %d
clo.cpp:57:26: warning: format '%ld' expects argument of type 'long int*', but argument 4 has type 'int*' [-Wformat=]
   57 |         scanf("%ld %ld %ld", &d[i].c, &d[i].f, &d[i].v);
      |                        ~~^                     ~~~~~~~
      |                          |                     |
      |                          long int*             int*
      |                        %d
clo.cpp:47:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |     scanf("%ld", &m);
      |     ~~~~~^~~~~~~~~~~
clo.cpp:50:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |         scanf("%ld %ld %ld", &t[i].c, &t[i].f, &t[i].v);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:54:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |     scanf("%ld", &n);
      |     ~~~~~^~~~~~~~~~~
clo.cpp:57:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |         scanf("%ld %ld %ld", &d[i].c, &d[i].f, &d[i].v);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1880 KB Output is correct
2 Correct 1 ms 1884 KB Output is correct
3 Correct 5 ms 2012 KB Output is correct
4 Correct 8 ms 2100 KB Output is correct
5 Correct 67 ms 2140 KB Output is correct
6 Correct 59 ms 2140 KB Output is correct
7 Correct 66 ms 2140 KB Output is correct
8 Correct 66 ms 2136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1880 KB Output is correct
2 Correct 1 ms 1884 KB Output is correct
3 Correct 1 ms 2008 KB Output is correct
4 Correct 1 ms 1880 KB Output is correct
5 Correct 3 ms 1884 KB Output is correct
6 Correct 3 ms 1884 KB Output is correct
7 Correct 6 ms 2140 KB Output is correct
8 Correct 6 ms 1996 KB Output is correct
9 Correct 7 ms 1884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1884 KB Output is correct
2 Correct 2 ms 1884 KB Output is correct
3 Correct 5 ms 1884 KB Output is correct
4 Correct 5 ms 1896 KB Output is correct
5 Correct 6 ms 2020 KB Output is correct
6 Correct 6 ms 1884 KB Output is correct
7 Correct 10 ms 1884 KB Output is correct
8 Correct 10 ms 1884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1884 KB Output is correct
2 Correct 1 ms 1884 KB Output is correct
3 Correct 3 ms 1884 KB Output is correct
4 Correct 57 ms 2108 KB Output is correct
5 Correct 585 ms 2140 KB Output is correct
6 Correct 717 ms 2136 KB Output is correct
7 Correct 835 ms 2136 KB Output is correct
8 Correct 821 ms 2172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1880 KB Output is correct
2 Correct 5 ms 1884 KB Output is correct
3 Correct 24 ms 2112 KB Output is correct
4 Correct 62 ms 1884 KB Output is correct
5 Correct 655 ms 2168 KB Output is correct
6 Correct 721 ms 2140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1880 KB Output is correct
2 Correct 1 ms 1884 KB Output is correct
3 Correct 5 ms 2012 KB Output is correct
4 Correct 8 ms 2100 KB Output is correct
5 Correct 67 ms 2140 KB Output is correct
6 Correct 59 ms 2140 KB Output is correct
7 Correct 66 ms 2140 KB Output is correct
8 Correct 66 ms 2136 KB Output is correct
9 Correct 1 ms 1880 KB Output is correct
10 Correct 1 ms 1884 KB Output is correct
11 Correct 1 ms 2008 KB Output is correct
12 Correct 1 ms 1880 KB Output is correct
13 Correct 3 ms 1884 KB Output is correct
14 Correct 3 ms 1884 KB Output is correct
15 Correct 6 ms 2140 KB Output is correct
16 Correct 6 ms 1996 KB Output is correct
17 Correct 7 ms 1884 KB Output is correct
18 Correct 2 ms 1884 KB Output is correct
19 Correct 2 ms 1884 KB Output is correct
20 Correct 5 ms 1884 KB Output is correct
21 Correct 5 ms 1896 KB Output is correct
22 Correct 6 ms 2020 KB Output is correct
23 Correct 6 ms 1884 KB Output is correct
24 Correct 10 ms 1884 KB Output is correct
25 Correct 10 ms 1884 KB Output is correct
26 Correct 2 ms 1884 KB Output is correct
27 Correct 1 ms 1884 KB Output is correct
28 Correct 3 ms 1884 KB Output is correct
29 Correct 57 ms 2108 KB Output is correct
30 Correct 585 ms 2140 KB Output is correct
31 Correct 717 ms 2136 KB Output is correct
32 Correct 835 ms 2136 KB Output is correct
33 Correct 821 ms 2172 KB Output is correct
34 Correct 2 ms 1880 KB Output is correct
35 Correct 5 ms 1884 KB Output is correct
36 Correct 24 ms 2112 KB Output is correct
37 Correct 62 ms 1884 KB Output is correct
38 Correct 655 ms 2168 KB Output is correct
39 Correct 721 ms 2140 KB Output is correct
40 Correct 64 ms 1884 KB Output is correct
41 Correct 171 ms 1880 KB Output is correct
42 Correct 69 ms 2140 KB Output is correct
43 Correct 724 ms 2172 KB Output is correct
44 Correct 772 ms 2176 KB Output is correct
45 Correct 629 ms 2204 KB Output is correct
46 Correct 42 ms 2140 KB Output is correct
47 Correct 73 ms 2068 KB Output is correct
48 Correct 71 ms 2124 KB Output is correct