Submission #1063088

#TimeUsernameProblemLanguageResultExecution timeMemory
1063088PotatoTheWarriorFRTTBulldozer (JOI17_bulldozer)C++14
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> using namespace std; long long MOD = 1000000000+7; typedef long long ll; typedef pair<pair<ll, ll>, ll> Point; int log2(int x) { int ln = -1; while(x > 0) { ln++; x/=2; } return ln; } bool comp(Point p1, Point p2) { return p1.first.first < p2.first.first; } void solve() { int n; cin >> n; vector<Point> points; for(int i=0;i<n;i++) { Point p; cin >> p.first.first >> p.first.second >> p.second; points.push_back(p); } sort(points.begin(), points.end(), comp); vector<ll> vals; for(int i=0;i<n;i++) { vals.push_back(0); ll X = points[i].first.first; while(points[i].first.first == X) { vals[vals.size()-1]+=points[i].second; i++; } i--; } ll S[vals.size()+1]; ll M[vals.size()+1]; S[0] = 0; M[0] = 0; for(int i=1;i<=vals.size();i++) { S[i] = S[i-1]+vals[i-1]; M[i] = min(M[i-1], M[i]); } ll ans = 0; for(int i=0;i<vals.size();i++) { ans = max(ans, S[i+1] - M[i]); } cout << ans << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int t; solve(); char sdhfn; cin >> sdhfn; }

Compilation message (stderr)

bulldozer.cpp: In function 'void solve()':
bulldozer.cpp:45:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for(int i=1;i<=vals.size();i++) {
      |                 ~^~~~~~~~~~~~~
bulldozer.cpp:50:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for(int i=0;i<vals.size();i++) {
      |                 ~^~~~~~~~~~~~
bulldozer.cpp: In function 'int main()':
bulldozer.cpp:60:9: warning: unused variable 't' [-Wunused-variable]
   60 |     int t;
      |         ^
#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...