Submission #1118178

#TimeUsernameProblemLanguageResultExecution timeMemory
1118178pemguimnBulldozer (JOI17_bulldozer)C++14
5 / 100
1 ms528 KiB
#include <bits/stdc++.h>
#define pii pair<int, int>
#define int long long

using namespace std;

const int N = 2e3 + 5;

struct pt{
    int x, y, w, id;
};

vector<pt> a; int n;

namespace sub1{
    void solve(){
        sort(a.begin(), a.end(), [](pt &x, pt &y){return x.x < y.x;});
        int ans = 0;
        for(int i = 0; i < n; i++){
            int sum = 0;
            for(int j = i; j < n; j++){
                sum += a[j].w;
                ans = max(ans, sum);
            }
        }
        cout << ans << '\n';
    }
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    #define task "truffle"
    if(fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }

    cin >> n;
    for(int i = 0; i < n; i++){
        int x, y, w; cin >> x >> y >> w;
        a.push_back({x, y, w, i});
    }

    sub1::solve();
//    full::solve();
    return 0;
}

/*
5
-5 5 -2
2 5 10
1 4 -2
4 -5 4
-2 2 7

6
0 0 6
1 0 -2
2 0 8
0 1 -2
1 1 5
2 1 -2

5
0 0 2
4 0 2
3 2 -1
1 2 2
1 1 -1

2
0 0 -1
1 0 -1
*/

Compilation message (stderr)

bulldozer.cpp: In function 'int main()':
bulldozer.cpp:36:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bulldozer.cpp:37:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...