답안 #995647

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
995647 2024-06-09T14:49:05 Z Luca1234 Art Exhibition (JOI18_art) C++14
50 / 100
1000 ms 20892 KB
#include <bits/stdc++.h>

using namespace std;

vector <pair <long long, int> > v;

int main()
{
    int n, val;
    long long sz;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>sz>>val;
        v.push_back({sz, val});
    }
    sort(v.begin(), v.end());
    long long last=-1;
    for(int i=0; i<v.size(); i++)
    {
        if(v[i].first==last)
        {
            v[i-1].second+=v[i].second;
            v.erase(v.begin()+i);
        }
        last=v[i].first;
    }
    int lg=v.size();
    long long ans=-1;
    for(int i=0; i<lg; i++)
    {
        long long sum=0;
        for(int j=i; j<lg; j++){
            sum+=v[j].second;
            if(sum-(v[j].first-v[i].first)>ans)
                ans=sum-(v[j].first-v[i].first);
        }
    }
    cout<<ans;

    return 0;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:19:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(int i=0; i<v.size(); i++)
      |                  ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 14 ms 604 KB Output is correct
28 Correct 14 ms 604 KB Output is correct
29 Correct 14 ms 700 KB Output is correct
30 Correct 15 ms 604 KB Output is correct
31 Correct 15 ms 740 KB Output is correct
32 Correct 14 ms 604 KB Output is correct
33 Correct 14 ms 700 KB Output is correct
34 Correct 14 ms 604 KB Output is correct
35 Correct 14 ms 768 KB Output is correct
36 Correct 14 ms 696 KB Output is correct
37 Correct 14 ms 692 KB Output is correct
38 Correct 15 ms 600 KB Output is correct
39 Correct 14 ms 604 KB Output is correct
40 Correct 14 ms 700 KB Output is correct
41 Correct 14 ms 600 KB Output is correct
42 Correct 15 ms 604 KB Output is correct
43 Correct 14 ms 604 KB Output is correct
44 Correct 14 ms 604 KB Output is correct
45 Correct 15 ms 604 KB Output is correct
46 Correct 15 ms 600 KB Output is correct
47 Correct 14 ms 604 KB Output is correct
48 Correct 18 ms 604 KB Output is correct
49 Correct 15 ms 604 KB Output is correct
50 Correct 17 ms 604 KB Output is correct
51 Correct 15 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 14 ms 604 KB Output is correct
28 Correct 14 ms 604 KB Output is correct
29 Correct 14 ms 700 KB Output is correct
30 Correct 15 ms 604 KB Output is correct
31 Correct 15 ms 740 KB Output is correct
32 Correct 14 ms 604 KB Output is correct
33 Correct 14 ms 700 KB Output is correct
34 Correct 14 ms 604 KB Output is correct
35 Correct 14 ms 768 KB Output is correct
36 Correct 14 ms 696 KB Output is correct
37 Correct 14 ms 692 KB Output is correct
38 Correct 15 ms 600 KB Output is correct
39 Correct 14 ms 604 KB Output is correct
40 Correct 14 ms 700 KB Output is correct
41 Correct 14 ms 600 KB Output is correct
42 Correct 15 ms 604 KB Output is correct
43 Correct 14 ms 604 KB Output is correct
44 Correct 14 ms 604 KB Output is correct
45 Correct 15 ms 604 KB Output is correct
46 Correct 15 ms 600 KB Output is correct
47 Correct 14 ms 604 KB Output is correct
48 Correct 18 ms 604 KB Output is correct
49 Correct 15 ms 604 KB Output is correct
50 Correct 17 ms 604 KB Output is correct
51 Correct 15 ms 604 KB Output is correct
52 Execution timed out 1036 ms 20892 KB Time limit exceeded
53 Halted 0 ms 0 KB -