Submission #580319

# Submission time Handle Problem Language Result Execution time Memory
580319 2022-06-21T05:19:33 Z temporary_juggernaut Cloud Computing (CEOI18_clo) C++14
100 / 100
434 ms 1228 KB
#include<bits/stdc++.h>
#define fr first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
#define USING_ORDERED_SET 0
#if USING_ORDERED_SET
#include<bits/extc++.h>
using namespace __gnu_pbds;
template<class T>using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
#endif
template<class T>void umax(T &a,T b){if(a<b)a=b;}
template<class T>void umin(T &a,T b){if(b<a)a=b;}
#ifdef juggernaut
    #define printl(args...) printf(args)
#else
    #define printl(args...) 0
#endif
struct dat{
	int core;
	int freq;
	int cost;
}a[4005];
int n,m;
bool cmp(dat l,dat r){
	if(l.freq==r.freq)return l.cost<r.cost;
	return l.freq>r.freq;
}
const int MX=100000;
ll dp[MX+5];
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d%d",&a[i].core,&a[i].freq,&a[i].cost);
		a[i].cost*=-1;
	}
	fill(dp,dp+MX+5,-1e15);
	dp[0]=0;
	scanf("%d",&m);
	for(int i=n;i<n+m;i++)scanf("%d%d%d",&a[i].core,&a[i].freq,&a[i].cost);
	sort(a,a+n+m,cmp);
	for(int i=0;i<n+m;i++){
		if(a[i].cost<0){
			for(int j=MX;j>=a[i].core;j--)
				umax(dp[j],dp[j-a[i].core]+a[i].cost);
		}else{
			for(int j=0;j<=MX-a[i].core;j++)
				umax(dp[j],dp[j+a[i].core]+a[i].cost);
		}
	}
	for(int i=1;i<=MX;i++)umax(dp[i],dp[i-1]);
	cout<<dp[MX];
}

Compilation message

clo.cpp: In function 'int main()':
clo.cpp:33:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
clo.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |   scanf("%d%d%d",&a[i].core,&a[i].freq,&a[i].cost);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:40:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |  scanf("%d",&m);
      |  ~~~~~^~~~~~~~~
clo.cpp:41:29: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |  for(int i=n;i<n+m;i++)scanf("%d%d%d",&a[i].core,&a[i].freq,&a[i].cost);
      |                        ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 9 ms 980 KB Output is correct
4 Correct 18 ms 980 KB Output is correct
5 Correct 174 ms 1132 KB Output is correct
6 Correct 165 ms 1108 KB Output is correct
7 Correct 163 ms 1136 KB Output is correct
8 Correct 211 ms 1132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 2 ms 980 KB Output is correct
3 Correct 9 ms 1108 KB Output is correct
4 Correct 10 ms 1088 KB Output is correct
5 Correct 67 ms 1076 KB Output is correct
6 Correct 68 ms 1076 KB Output is correct
7 Correct 178 ms 1108 KB Output is correct
8 Correct 151 ms 1132 KB Output is correct
9 Correct 151 ms 1100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 980 KB Output is correct
2 Correct 4 ms 1084 KB Output is correct
3 Correct 18 ms 1088 KB Output is correct
4 Correct 17 ms 980 KB Output is correct
5 Correct 28 ms 980 KB Output is correct
6 Correct 28 ms 980 KB Output is correct
7 Correct 37 ms 980 KB Output is correct
8 Correct 38 ms 1064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 980 KB Output is correct
2 Correct 2 ms 980 KB Output is correct
3 Correct 118 ms 1080 KB Output is correct
4 Correct 143 ms 980 KB Output is correct
5 Correct 312 ms 1108 KB Output is correct
6 Correct 387 ms 1148 KB Output is correct
7 Correct 318 ms 1160 KB Output is correct
8 Correct 322 ms 1228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 980 KB Output is correct
2 Correct 14 ms 980 KB Output is correct
3 Correct 61 ms 980 KB Output is correct
4 Correct 147 ms 1084 KB Output is correct
5 Correct 434 ms 1184 KB Output is correct
6 Correct 385 ms 1208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 9 ms 980 KB Output is correct
4 Correct 18 ms 980 KB Output is correct
5 Correct 174 ms 1132 KB Output is correct
6 Correct 165 ms 1108 KB Output is correct
7 Correct 163 ms 1136 KB Output is correct
8 Correct 211 ms 1132 KB Output is correct
9 Correct 1 ms 980 KB Output is correct
10 Correct 2 ms 980 KB Output is correct
11 Correct 9 ms 1108 KB Output is correct
12 Correct 10 ms 1088 KB Output is correct
13 Correct 67 ms 1076 KB Output is correct
14 Correct 68 ms 1076 KB Output is correct
15 Correct 178 ms 1108 KB Output is correct
16 Correct 151 ms 1132 KB Output is correct
17 Correct 151 ms 1100 KB Output is correct
18 Correct 3 ms 980 KB Output is correct
19 Correct 4 ms 1084 KB Output is correct
20 Correct 18 ms 1088 KB Output is correct
21 Correct 17 ms 980 KB Output is correct
22 Correct 28 ms 980 KB Output is correct
23 Correct 28 ms 980 KB Output is correct
24 Correct 37 ms 980 KB Output is correct
25 Correct 38 ms 1064 KB Output is correct
26 Correct 2 ms 980 KB Output is correct
27 Correct 2 ms 980 KB Output is correct
28 Correct 118 ms 1080 KB Output is correct
29 Correct 143 ms 980 KB Output is correct
30 Correct 312 ms 1108 KB Output is correct
31 Correct 387 ms 1148 KB Output is correct
32 Correct 318 ms 1160 KB Output is correct
33 Correct 322 ms 1228 KB Output is correct
34 Correct 2 ms 980 KB Output is correct
35 Correct 14 ms 980 KB Output is correct
36 Correct 61 ms 980 KB Output is correct
37 Correct 147 ms 1084 KB Output is correct
38 Correct 434 ms 1184 KB Output is correct
39 Correct 385 ms 1208 KB Output is correct
40 Correct 101 ms 1088 KB Output is correct
41 Correct 176 ms 1108 KB Output is correct
42 Correct 257 ms 1140 KB Output is correct
43 Correct 346 ms 1156 KB Output is correct
44 Correct 350 ms 1164 KB Output is correct
45 Correct 329 ms 1196 KB Output is correct
46 Correct 159 ms 1112 KB Output is correct
47 Correct 220 ms 1152 KB Output is correct
48 Correct 236 ms 1144 KB Output is correct