답안 #1115357

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1115357 2024-11-20T11:22:34 Z staszic_ojuz Art Exhibition (JOI18_art) C++17
50 / 100
1000 ms 72348 KB
#include<bits/stdc++.h>
using namespace std;
int main() {
    long long n, wiel, wart, l = 0, p = 0, overall = 0;
    cin >> n;
    map<long long, long long> m;
    vector<vector<long long>> v;
    for (int i = 0; i < n; i++) {
        cin >> wiel >> wart;
        m[wiel] += wart;
        overall += wart;
    }
    for (auto [wie, war] : m) {
        v.push_back({wie, war});
    }
    long long wyn = 0, suma = v[0][1], osw = v[v.size() - 1][0];
    for(int i = 0; i < v.size(); i++) {
        //cout << overall << " " << osw << " " << v[i][0] << endl;
        if (overall - osw + v[i][0] > wyn) {
            wyn = overall - osw + v[i][0];
        }
        if (v[i][1] > wyn) {
            wyn = v[i][1];
        }
        overall -= v[i][1];
    }
    while (l < v.size()) {
        //cout << suma << " " << v[l][0] << " " << p << endl;
        if ((l >= p) || (p < v.size() && suma - v[p][0] + v[l][0] > v[p][1])) {
            if (suma - v[p][0] + v[l][0] > wyn) {
                wyn = suma - v[p][0] + v[l][0];
            }
            p += 1;
            if (p < v.size() - 1) {
                suma += v[p][1];
            }
        }
        else {
            suma -= v[l][1];
            l += 1;
        }
    }
    cout << wyn;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:17:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i = 0; i < v.size(); i++) {
      |                    ~~^~~~~~~~~~
art.cpp:27:14: 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]
   27 |     while (l < v.size()) {
      |            ~~^~~~~~~~~~
art.cpp:29:28: 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]
   29 |         if ((l >= p) || (p < v.size() && suma - v[p][0] + v[l][0] > v[p][1])) {
      |                          ~~^~~~~~~~~~
art.cpp:34:19: 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]
   34 |             if (p < v.size() - 1) {
      |                 ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 504 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 504 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 504 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 504 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 2 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 2 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 2 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 2 ms 504 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 504 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 504 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 2 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 2 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 2 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 2 ms 504 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 5 ms 892 KB Output is correct
28 Correct 9 ms 860 KB Output is correct
29 Correct 6 ms 848 KB Output is correct
30 Correct 6 ms 848 KB Output is correct
31 Correct 6 ms 904 KB Output is correct
32 Correct 6 ms 848 KB Output is correct
33 Correct 5 ms 992 KB Output is correct
34 Correct 5 ms 848 KB Output is correct
35 Correct 5 ms 848 KB Output is correct
36 Correct 5 ms 848 KB Output is correct
37 Correct 7 ms 848 KB Output is correct
38 Correct 5 ms 848 KB Output is correct
39 Correct 5 ms 988 KB Output is correct
40 Correct 5 ms 848 KB Output is correct
41 Correct 8 ms 848 KB Output is correct
42 Correct 5 ms 980 KB Output is correct
43 Correct 6 ms 848 KB Output is correct
44 Correct 5 ms 984 KB Output is correct
45 Correct 8 ms 848 KB Output is correct
46 Correct 6 ms 1016 KB Output is correct
47 Correct 9 ms 848 KB Output is correct
48 Correct 5 ms 848 KB Output is correct
49 Correct 5 ms 1052 KB Output is correct
50 Correct 6 ms 848 KB Output is correct
51 Correct 5 ms 848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 504 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 504 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 2 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 2 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 2 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 2 ms 504 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 5 ms 892 KB Output is correct
28 Correct 9 ms 860 KB Output is correct
29 Correct 6 ms 848 KB Output is correct
30 Correct 6 ms 848 KB Output is correct
31 Correct 6 ms 904 KB Output is correct
32 Correct 6 ms 848 KB Output is correct
33 Correct 5 ms 992 KB Output is correct
34 Correct 5 ms 848 KB Output is correct
35 Correct 5 ms 848 KB Output is correct
36 Correct 5 ms 848 KB Output is correct
37 Correct 7 ms 848 KB Output is correct
38 Correct 5 ms 848 KB Output is correct
39 Correct 5 ms 988 KB Output is correct
40 Correct 5 ms 848 KB Output is correct
41 Correct 8 ms 848 KB Output is correct
42 Correct 5 ms 980 KB Output is correct
43 Correct 6 ms 848 KB Output is correct
44 Correct 5 ms 984 KB Output is correct
45 Correct 8 ms 848 KB Output is correct
46 Correct 6 ms 1016 KB Output is correct
47 Correct 9 ms 848 KB Output is correct
48 Correct 5 ms 848 KB Output is correct
49 Correct 5 ms 1052 KB Output is correct
50 Correct 6 ms 848 KB Output is correct
51 Correct 5 ms 848 KB Output is correct
52 Correct 757 ms 59620 KB Output is correct
53 Correct 775 ms 72244 KB Output is correct
54 Correct 907 ms 72296 KB Output is correct
55 Correct 867 ms 72100 KB Output is correct
56 Correct 914 ms 72348 KB Output is correct
57 Correct 855 ms 72172 KB Output is correct
58 Correct 866 ms 72168 KB Output is correct
59 Correct 877 ms 72108 KB Output is correct
60 Correct 905 ms 71596 KB Output is correct
61 Correct 813 ms 71992 KB Output is correct
62 Correct 843 ms 72164 KB Output is correct
63 Correct 837 ms 72232 KB Output is correct
64 Correct 762 ms 72128 KB Output is correct
65 Correct 747 ms 72344 KB Output is correct
66 Correct 840 ms 72096 KB Output is correct
67 Execution timed out 1045 ms 35400 KB Time limit exceeded
68 Halted 0 ms 0 KB -