Submission #567886

# Submission time Handle Problem Language Result Execution time Memory
567886 2022-05-24T09:53:40 Z ShivanshJ Cloud Computing (CEOI18_clo) C++17
100 / 100
553 ms 2252 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MAX=1e5+5;
const int INF=1e18;
const int MOD=1e9+7;
const int MAXL=61;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout<<setprecision(6)<<fixed;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n,m;
    cin>>n;
    vector<vector<int>>info; //freq, -delta profit, delta core
    for(int i=0;i<n;i++) {
        int c,f,v;
        cin>>c>>f>>v;
        info.push_back({f,v,c});
    }
    cin>>m;
    for(int i=0;i<m;i++) {
        int c,f,v;
        cin>>c>>f>>v;
        info.push_back({f,-v,-c});
    }
    sort(info.begin(),info.end(),greater<vector<int>>());
    int dp[MAX][2];
    for(int i=1;i<MAX;i++) {
        dp[i][1]=-INF;
    }
    dp[0][1]=0;
    int curr=0;
    for(int i=0;i<info.size();i++) {
        for(int j=0;j<MAX;j++) {
            dp[j][curr]=dp[j][curr^1];
            if(j-info[i][2]>=0 && j-info[i][2]<MAX) {
                dp[j][curr]=max(dp[j][curr],dp[j-info[i][2]][curr^1]-info[i][1]);
            }
        }
        curr^=1;
    }
    curr^=1;
    int ans=0;
    for(int i=0;i<MAX;i++) {
        ans=max(ans,dp[i][curr]);
    }
    cout<<ans;
    return 0;
}

Compilation message

clo.cpp: In function 'int main()':
clo.cpp:36:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(int i=0;i<info.size();i++) {
      |                 ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 14 ms 1876 KB Output is correct
4 Correct 26 ms 1876 KB Output is correct
5 Correct 234 ms 1876 KB Output is correct
6 Correct 261 ms 1976 KB Output is correct
7 Correct 264 ms 2124 KB Output is correct
8 Correct 254 ms 2016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1876 KB Output is correct
2 Correct 3 ms 1876 KB Output is correct
3 Correct 15 ms 1876 KB Output is correct
4 Correct 15 ms 1892 KB Output is correct
5 Correct 116 ms 1916 KB Output is correct
6 Correct 111 ms 1920 KB Output is correct
7 Correct 281 ms 1996 KB Output is correct
8 Correct 245 ms 1976 KB Output is correct
9 Correct 237 ms 1992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1876 KB Output is correct
2 Correct 5 ms 1876 KB Output is correct
3 Correct 32 ms 1880 KB Output is correct
4 Correct 27 ms 1900 KB Output is correct
5 Correct 48 ms 1876 KB Output is correct
6 Correct 46 ms 1888 KB Output is correct
7 Correct 62 ms 1900 KB Output is correct
8 Correct 62 ms 1900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1876 KB Output is correct
2 Correct 3 ms 1876 KB Output is correct
3 Correct 213 ms 1956 KB Output is correct
4 Correct 213 ms 1972 KB Output is correct
5 Correct 479 ms 2072 KB Output is correct
6 Correct 521 ms 2252 KB Output is correct
7 Correct 499 ms 2148 KB Output is correct
8 Correct 522 ms 2132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1748 KB Output is correct
2 Correct 23 ms 1876 KB Output is correct
3 Correct 110 ms 1916 KB Output is correct
4 Correct 259 ms 1972 KB Output is correct
5 Correct 491 ms 2092 KB Output is correct
6 Correct 505 ms 2088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 14 ms 1876 KB Output is correct
4 Correct 26 ms 1876 KB Output is correct
5 Correct 234 ms 1876 KB Output is correct
6 Correct 261 ms 1976 KB Output is correct
7 Correct 264 ms 2124 KB Output is correct
8 Correct 254 ms 2016 KB Output is correct
9 Correct 2 ms 1876 KB Output is correct
10 Correct 3 ms 1876 KB Output is correct
11 Correct 15 ms 1876 KB Output is correct
12 Correct 15 ms 1892 KB Output is correct
13 Correct 116 ms 1916 KB Output is correct
14 Correct 111 ms 1920 KB Output is correct
15 Correct 281 ms 1996 KB Output is correct
16 Correct 245 ms 1976 KB Output is correct
17 Correct 237 ms 1992 KB Output is correct
18 Correct 5 ms 1876 KB Output is correct
19 Correct 5 ms 1876 KB Output is correct
20 Correct 32 ms 1880 KB Output is correct
21 Correct 27 ms 1900 KB Output is correct
22 Correct 48 ms 1876 KB Output is correct
23 Correct 46 ms 1888 KB Output is correct
24 Correct 62 ms 1900 KB Output is correct
25 Correct 62 ms 1900 KB Output is correct
26 Correct 3 ms 1876 KB Output is correct
27 Correct 3 ms 1876 KB Output is correct
28 Correct 213 ms 1956 KB Output is correct
29 Correct 213 ms 1972 KB Output is correct
30 Correct 479 ms 2072 KB Output is correct
31 Correct 521 ms 2252 KB Output is correct
32 Correct 499 ms 2148 KB Output is correct
33 Correct 522 ms 2132 KB Output is correct
34 Correct 2 ms 1748 KB Output is correct
35 Correct 23 ms 1876 KB Output is correct
36 Correct 110 ms 1916 KB Output is correct
37 Correct 259 ms 1972 KB Output is correct
38 Correct 491 ms 2092 KB Output is correct
39 Correct 505 ms 2088 KB Output is correct
40 Correct 128 ms 1936 KB Output is correct
41 Correct 291 ms 2004 KB Output is correct
42 Correct 366 ms 2092 KB Output is correct
43 Correct 487 ms 2116 KB Output is correct
44 Correct 553 ms 2144 KB Output is correct
45 Correct 482 ms 2180 KB Output is correct
46 Correct 262 ms 2004 KB Output is correct
47 Correct 370 ms 2092 KB Output is correct
48 Correct 386 ms 2096 KB Output is correct