Submission #244208

# Submission time Handle Problem Language Result Execution time Memory
244208 2020-07-02T21:04:13 Z kimbj0709 Art Exhibition (JOI18_art) C++14
100 / 100
307 ms 33272 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  int no_of_input;
  int input1,input2;
  vector<pair<int,int> > vect1;
  cin >> no_of_input;
  for(int i=0;i<no_of_input;i++){
    cin >> input1 >> input2;
    vect1.push_back({input1,input2});
  }
  sort(vect1.begin(),vect1.end());
  vector<pair<int,int> > vect2;
  for(int i=0;i<vect1.size();){
    int currpos = i;
    int currsum = 0;
    while(i<vect1.size()&&vect1[i].f==vect1[currpos].f){
      currsum += vect1[i].s;
      i++;
    }
    vect2.push_back({vect1[currpos].f,currsum});
  }
  int ans = 0;
  int curr = 0;
  ans = max(ans,vect2[0].s);
  for(int i=1;i<vect2.size();i++){
    curr += vect2[i-1].s-(vect2[i].f-vect2[i-1].f);
    curr = max(curr,(int)0);
    ans = max(ans,curr+vect2[i].s);
  }
  cout << ans;
}

Compilation message

art.cpp: In function 'int32_t main()':
art.cpp:19:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<vect1.size();){
               ~^~~~~~~~~~~~~
art.cpp:22:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(i<vect1.size()&&vect1[i].f==vect1[currpos].f){
           ~^~~~~~~~~~~~~
art.cpp:31:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=1;i<vect2.size();i++){
               ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 512 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 512 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 7 ms 768 KB Output is correct
28 Correct 7 ms 768 KB Output is correct
29 Correct 7 ms 768 KB Output is correct
30 Correct 7 ms 768 KB Output is correct
31 Correct 7 ms 768 KB Output is correct
32 Correct 7 ms 768 KB Output is correct
33 Correct 7 ms 768 KB Output is correct
34 Correct 7 ms 768 KB Output is correct
35 Correct 8 ms 768 KB Output is correct
36 Correct 7 ms 768 KB Output is correct
37 Correct 7 ms 816 KB Output is correct
38 Correct 7 ms 768 KB Output is correct
39 Correct 7 ms 768 KB Output is correct
40 Correct 8 ms 768 KB Output is correct
41 Correct 7 ms 768 KB Output is correct
42 Correct 7 ms 768 KB Output is correct
43 Correct 7 ms 768 KB Output is correct
44 Correct 7 ms 768 KB Output is correct
45 Correct 7 ms 768 KB Output is correct
46 Correct 7 ms 768 KB Output is correct
47 Correct 7 ms 768 KB Output is correct
48 Correct 7 ms 768 KB Output is correct
49 Correct 7 ms 768 KB Output is correct
50 Correct 7 ms 768 KB Output is correct
51 Correct 7 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 512 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 7 ms 768 KB Output is correct
28 Correct 7 ms 768 KB Output is correct
29 Correct 7 ms 768 KB Output is correct
30 Correct 7 ms 768 KB Output is correct
31 Correct 7 ms 768 KB Output is correct
32 Correct 7 ms 768 KB Output is correct
33 Correct 7 ms 768 KB Output is correct
34 Correct 7 ms 768 KB Output is correct
35 Correct 8 ms 768 KB Output is correct
36 Correct 7 ms 768 KB Output is correct
37 Correct 7 ms 816 KB Output is correct
38 Correct 7 ms 768 KB Output is correct
39 Correct 7 ms 768 KB Output is correct
40 Correct 8 ms 768 KB Output is correct
41 Correct 7 ms 768 KB Output is correct
42 Correct 7 ms 768 KB Output is correct
43 Correct 7 ms 768 KB Output is correct
44 Correct 7 ms 768 KB Output is correct
45 Correct 7 ms 768 KB Output is correct
46 Correct 7 ms 768 KB Output is correct
47 Correct 7 ms 768 KB Output is correct
48 Correct 7 ms 768 KB Output is correct
49 Correct 7 ms 768 KB Output is correct
50 Correct 7 ms 768 KB Output is correct
51 Correct 7 ms 760 KB Output is correct
52 Correct 242 ms 33192 KB Output is correct
53 Correct 247 ms 33108 KB Output is correct
54 Correct 232 ms 33084 KB Output is correct
55 Correct 239 ms 33208 KB Output is correct
56 Correct 240 ms 33108 KB Output is correct
57 Correct 240 ms 33108 KB Output is correct
58 Correct 235 ms 33240 KB Output is correct
59 Correct 251 ms 33272 KB Output is correct
60 Correct 238 ms 33108 KB Output is correct
61 Correct 238 ms 33080 KB Output is correct
62 Correct 249 ms 33108 KB Output is correct
63 Correct 231 ms 33240 KB Output is correct
64 Correct 244 ms 33236 KB Output is correct
65 Correct 239 ms 33112 KB Output is correct
66 Correct 238 ms 33108 KB Output is correct
67 Correct 230 ms 33112 KB Output is correct
68 Correct 307 ms 33108 KB Output is correct