Submission #710843

# Submission time Handle Problem Language Result Execution time Memory
710843 2023-03-15T23:51:49 Z Jovan26 Art Exhibition (JOI18_art) C++14
100 / 100
684 ms 50044 KB
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	#define int long long
	int n;
	cin>>n;
	int a1[n];
	int b[n];
	map<int, int> mapa;
	for(int i=0;i<n;i++){
		cin>>a1[i]>>b[i];
		mapa[a1[i]]+=b[i];
	}
	sort(a1,a1+n);
	vector<int> a;
	for(int i=0;i<n;i++){
		if(i==0 || a1[i]!=a1[i-1]) a.push_back(a1[i]);
	}
	//int o = 0;
	int dp[a.size()];
	dp[0] = mapa[a[0]];
	int o = dp[0];
	for(int i=1;i<a.size();i++){
		//if(i!=0 && a[i]==a[i-1]) continue;
			dp[i] = max(dp[i-1]-a[i]+a[i-1]+mapa[a[i]], mapa[a[i]]);
			o = max(o, dp[i]);
	}
	//cout<<dp[1].second<<endl;
	cout<<o<<endl;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:25:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for(int i=1;i<a.size();i++){
      |              ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 5 ms 724 KB Output is correct
28 Correct 6 ms 852 KB Output is correct
29 Correct 4 ms 852 KB Output is correct
30 Correct 4 ms 852 KB Output is correct
31 Correct 4 ms 852 KB Output is correct
32 Correct 3 ms 852 KB Output is correct
33 Correct 4 ms 724 KB Output is correct
34 Correct 3 ms 848 KB Output is correct
35 Correct 4 ms 852 KB Output is correct
36 Correct 3 ms 852 KB Output is correct
37 Correct 4 ms 852 KB Output is correct
38 Correct 3 ms 724 KB Output is correct
39 Correct 3 ms 852 KB Output is correct
40 Correct 5 ms 852 KB Output is correct
41 Correct 4 ms 852 KB Output is correct
42 Correct 5 ms 852 KB Output is correct
43 Correct 5 ms 852 KB Output is correct
44 Correct 4 ms 852 KB Output is correct
45 Correct 4 ms 852 KB Output is correct
46 Correct 4 ms 852 KB Output is correct
47 Correct 4 ms 724 KB Output is correct
48 Correct 3 ms 852 KB Output is correct
49 Correct 4 ms 852 KB Output is correct
50 Correct 3 ms 852 KB Output is correct
51 Correct 3 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 5 ms 724 KB Output is correct
28 Correct 6 ms 852 KB Output is correct
29 Correct 4 ms 852 KB Output is correct
30 Correct 4 ms 852 KB Output is correct
31 Correct 4 ms 852 KB Output is correct
32 Correct 3 ms 852 KB Output is correct
33 Correct 4 ms 724 KB Output is correct
34 Correct 3 ms 848 KB Output is correct
35 Correct 4 ms 852 KB Output is correct
36 Correct 3 ms 852 KB Output is correct
37 Correct 4 ms 852 KB Output is correct
38 Correct 3 ms 724 KB Output is correct
39 Correct 3 ms 852 KB Output is correct
40 Correct 5 ms 852 KB Output is correct
41 Correct 4 ms 852 KB Output is correct
42 Correct 5 ms 852 KB Output is correct
43 Correct 5 ms 852 KB Output is correct
44 Correct 4 ms 852 KB Output is correct
45 Correct 4 ms 852 KB Output is correct
46 Correct 4 ms 852 KB Output is correct
47 Correct 4 ms 724 KB Output is correct
48 Correct 3 ms 852 KB Output is correct
49 Correct 4 ms 852 KB Output is correct
50 Correct 3 ms 852 KB Output is correct
51 Correct 3 ms 852 KB Output is correct
52 Correct 642 ms 47336 KB Output is correct
53 Correct 616 ms 47440 KB Output is correct
54 Correct 615 ms 47316 KB Output is correct
55 Correct 659 ms 47296 KB Output is correct
56 Correct 684 ms 49672 KB Output is correct
57 Correct 625 ms 49908 KB Output is correct
58 Correct 637 ms 49840 KB Output is correct
59 Correct 609 ms 49884 KB Output is correct
60 Correct 669 ms 49768 KB Output is correct
61 Correct 653 ms 49768 KB Output is correct
62 Correct 631 ms 49876 KB Output is correct
63 Correct 645 ms 50044 KB Output is correct
64 Correct 663 ms 49832 KB Output is correct
65 Correct 646 ms 49772 KB Output is correct
66 Correct 657 ms 49584 KB Output is correct
67 Correct 674 ms 49496 KB Output is correct
68 Correct 624 ms 49696 KB Output is correct