답안 #1063236

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1063236 2024-08-17T15:38:38 Z PotatoTheWarriorFRTT Bulldozer (JOI17_bulldozer) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
 
long long MOD = 1000000000+7;
typedef long long ll;
typedef pair<pair<ll, ll>, pair<ll, ll>> Point;

int log2(int x) {
    int ln = -1;
    while(x > 0) {
        ln++;
        x/=2;
    }
    return ln;
}
 
bool comp(Point p1, Point p2) {
    return p1.second.second < p2.second.second;
}

ll max_sub_sum(vector<ll> &vals) {
    ll S[vals.size()+1];
    ll M[vals.size()+1];
    S[0] = 0;
    M[0] = 0;
    for(int i=1;i<=vals.size();i++) {
        S[i] = S[i-1]+vals[i-1];
        M[i] = min(M[i-1], S[i]);
    }
    ll ans = 0;
    for(int i=0;i<vals.size();i++) {
        ans = max(ans, S[i+1] - M[i+1]);
    }
    return ans;
}

void solve() {
    int n; cin >> n;
    vector<Point> points;
    for(int i=0;i<n;i++) {
        Point p;
        cin >> p.first.first >> p.first.second >> p.second.first;
        points.push_back(p);
    }
    ll ans = max(0, points[0].second.first);
    for(int i=0;i<n;i++) {
        for(int j=i+1;j<n;j++) {
            // pair<ll, ll> dir = {points[i].first.first - points[j].first.first, points[i].first.second - points[j].first.second};
            pair<ll, ll> dir = {1, 0};
            if(dir.first != 0 || dir.second != 0) {
                for(int k=0;k<n;k++) {
                    points[k].second.second = dir.first * points[k].first.first + dir.second * points[k].first.second;
                }
                sort(points.begin(), points.end(), comp);
                vector<ll> vals;
                for(int k=0;k<n;k++) {
                    vals.push_back(0);
                    ll X = points[k].second.second;
                    while(points[k].second.second == X) {
                        vals[vals.size()-1]+=points[k].second.first;
                        k++;
                    }
                    k--;
                }

                ans = max(ans, max_sub_sum(vals));
            }
        }
    }
    cout << ans << endl;
}
 
int main()   {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // int t;
    // cin >> t;
    // while (t--)
        solve();
    char sdhfn;
    cin >> sdhfn;
}

Compilation message

bulldozer.cpp: In function 'll max_sub_sum(std::vector<long long int>&)':
bulldozer.cpp:26:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i=1;i<=vals.size();i++) {
      |                 ~^~~~~~~~~~~~~
bulldozer.cpp:31:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i=0;i<vals.size();i++) {
      |                 ~^~~~~~~~~~~~
bulldozer.cpp: In function 'void solve()':
bulldozer.cpp:45:43: error: no matching function for call to 'max(int, long long int&)'
   45 |     ll ans = max(0, points[0].second.first);
      |                                           ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from bulldozer.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
bulldozer.cpp:45:43: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   45 |     ll ans = max(0, points[0].second.first);
      |                                           ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from bulldozer.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
bulldozer.cpp:45:43: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   45 |     ll ans = max(0, points[0].second.first);
      |                                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from bulldozer.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
bulldozer.cpp:45:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   45 |     ll ans = max(0, points[0].second.first);
      |                                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from bulldozer.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
bulldozer.cpp:45:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   45 |     ll ans = max(0, points[0].second.first);
      |                                           ^