Submission #338474

#TimeUsernameProblemLanguageResultExecution timeMemory
338474kiennguyen246Bulldozer (JOI17_bulldozer)C++14
5 / 100
1 ms364 KiB
/** * \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 (stderr)

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);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...