Submission #90052

# Submission time Handle Problem Language Result Execution time Memory
90052 2018-12-20T01:57:10 Z xiaowuc1 Art Exhibition (JOI18_art) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> edge;
typedef pair<int, ll> pill;
typedef pair<pill, int> data;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

pll l[500000];
int n;

void solve() {
  {
    int k;
    cin >> k;
    vector<pll> v;
    while(k--) {
      ll a, b;
      cin >> a >> b;
      v.push_back({a, b});
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < v.size();) {
      int j = i;
      while(j < v.size() && v[i].first == v[j].first) {
        l[n].second += v[j++].second;
      }
      l[n++].first = v[(i=j)-1].first;
    }
  }
  ll ret = l[0].second;
  ll sum = l[0].second;
  for(int i = 1; i < n; i++) {
    sum += l[i].second;
    sum -= (l[i].first - l[i-1].first);
    ret = max(ret, sum);
    sum = max(sum, l[i].second);
  }
  cout << ret << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}

Compilation message

art.cpp: In function 'void solve()':
art.cpp:29:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < v.size();) {
                    ~~^~~~~~~~~~
art.cpp:31:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       while(j < v.size() && v[i].first == v[j].first) {
             ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -