답안 #338474

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
338474 2020-12-23T08:56:05 Z kiennguyen246 Bulldozer (JOI17_bulldozer) C++14
5 / 100
1 ms 364 KB
/**
 * \author : Nguyen Duc Kien
 * \date : 23/12/2020
 * \version : 6.3.1
 */

///Task name
#define TASK "BULLDOZER"

/**--------------------------------------------------**/

#include <bits/stdc++.h>

using namespace std;

const int maxn = 2005;

int n;
struct point
{
    int x, y, w;

    void inp()
    {
        cin >> x >> y >> w;
    }
}a[maxn];

bool by_x(point u, point v)
{
    return (u.x < v.x);
}

namespace Sub1
{
    long long sx[maxn], res;

    void Main()
    {
        sort(a + 1, a + n + 1, by_x);
        for (int i = 1; i <= n; i ++)
            sx[i] = sx[i - 1] + a[i].w;
        for (int i = 1; i <= n; i ++)
            for (int j = i; j <= n; j ++)
                res = max(res, sx[j] - sx[i - 1]);
        cout << res;
    }
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cerr << "Processing...\n\n";
	if (fopen(TASK".INP", "r"))
	{
		freopen(TASK".INP", "r", stdin);
		freopen(TASK".OUT", "w", stdout);
	}

	cin >> n;
	for (int i = 1; i <= n; i ++) a[i].inp();
	bool all_ox = 1;
	for (int i = 1; i <= n; i ++)
        if (a[i].y != 0) all_ox = 1;
    if (all_ox) Sub1::Main();

	cerr << "\n\n--------------\n";
	return 0;
}

Compilation message

bulldozer.cpp: In function 'int main()':
bulldozer.cpp:57:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   57 |   freopen(TASK".INP", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bulldozer.cpp:58:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   58 |   freopen(TASK".OUT", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Incorrect 1 ms 364 KB Output isn't correct
17 Halted 0 ms 0 KB -