Submission #135335

#TimeUsernameProblemLanguageResultExecution timeMemory
135335Just_Solve_The_ProblemBulldozer (JOI17_bulldozer)C++11
0 / 100
2 ms376 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const int N = (int)2e3 + 7; int a[N]; int x[N], y[N], w[N], pos[N]; int n; ll pref[N]; main() { scanf("%d", &n); iota(pos, pos + n, 0); for (int i = 0; i < n; i++) { scanf("%d %d %d", &x[i], &y[i], &w[i]); } sort(pos, pos + n, [&](const int &A, const int &B){ return x[A] < x[B]; }); ll mn = 0, ans = 0; for (int i = 0; i < n; i++) { if (i) pref[i] = pref[i - 1]; pref[i] += w[pos[i]]; ans += (pref[i] - mn); mn = min(mn, pref[i]); } cout << ans; }

Compilation message (stderr)

bulldozer.cpp:14:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
bulldozer.cpp: In function 'int main()':
bulldozer.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &n);
   ~~~~~^~~~~~~~~~
bulldozer.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d", &x[i], &y[i], &w[i]);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...