답안 #895003

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
895003 2023-12-29T10:29:48 Z tamyte Bulldozer (JOI17_bulldozer) C++14
5 / 100
1 ms 424 KB
#include<bits/stdc++.h>
#define int int64_t
#define all(x) (x).begin(), (x).end()
#define UNIQUE(x) \
  sort(all(x)), x.erase(unique(all(x)), x.end()), x.shrink_to_fit()
using pii = std::pair<int, int>;
using namespace std;

void setIO(string name = "")
{
    cin.tie(0)->sync_with_stdio(0); // see /general/fast-io
    if (name.size())
    {
        freopen((name + ".in").c_str(), "r", stdin); // see /general/input-output
        freopen((name + ".out").c_str(), "w", stdout);
    }
}
int MOD = 1e9 + 7;
int oo = 1e18;



struct st
{
    int x, y, c;
};




void solve() {
    #define test1
    int n;
    cin >> n;
    vector<st> arr(n);
    for (int i = 0; i < n; ++i) {
        cin >> arr[i].x >> arr[i].y >> arr[i].c;
    }
    sort(arr.begin(), arr.end(), [&](const st& a, const st& b) {
        return a.x < b.x;
    });
    int mx = 0, curr = 0;
    for (int i = 0; i < n; ++i) {
        // cout << arr[i].c << " -> ";
        curr = max((int)0, curr + arr[i].c);
        mx = max(mx, curr);
        // cout << curr << " -> ";
    }
    // cout << "\n";
    // cout << mx << " ";
    // sort(arr.begin(), arr.end(), [&](const st& a, const st& b) {
    //     return a.y < b.y;
    // });
    // curr = 0;
    // for (int i = 0; i < n; ++i) {
    //     curr = max((int)0, curr + arr[i].c);
    //     mx = max(mx, curr);
    // }
    cout << mx;
} 




int32_t main () {
    setIO(""); int t = 1;
    #ifdef test
    cin >> t;
    #endif
    while (t--) solve();
}

Compilation message

bulldozer.cpp: In function 'void setIO(std::string)':
bulldozer.cpp:14:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         freopen((name + ".in").c_str(), "r", stdin); // see /general/input-output
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bulldozer.cpp:15:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         freopen((name + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 424 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 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 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 424 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 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 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Incorrect 0 ms 348 KB Output isn't correct
17 Halted 0 ms 0 KB -