제출 #699548

#제출 시각아이디문제언어결과실행 시간메모리
699548Galal012Art Exhibition (JOI18_art)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
using namespace std;
signed main()
{
    IOS;
    int n, ans = 0, l = 1, r = 1, cur = -1;
    cin >> n;
    pair <int, int> pr[n+1];
    pr[0].first = pr[0].second = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> pr[i].first >> pr[i].second;
        ans = max(ans, pr[i].second);
    }
    sort(pr, pr+n+1);
    for (int i = 1; i <= n; i++)
        pr[i].second += pr[i-1].second;
    while (l <= n && r <= n)
    {
        cout << l << " " << r << "\n";
        int tot = pr[r].second - pr[l-1].second;
        int dif = pr[r].first-pr[l].first;
        ans = max(ans, tot-dif);
        if (l == r)
        {
            cur = pr[r].second-pr[l-1].second;
            r++;
        }
        else if (r == n)
            l++;
        else
        {
            int n_tot = pr[r+1].second - pr[l-1].second;
            int n_dif = pr[r+1].first-pr[l].first;
            if (n_tot - n_dif >= tot-dif)
            {
                cur = n_tot-n_dif;
                r++;
            }
            else
            {
                l++;
                cur = (pr[r].second - pr[l-1].second) - (pr[r].first-pr[l].first);
            }
        }
    }
    cout << ans;
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

art.cpp: In function 'int main()':
art.cpp:8:35: warning: variable 'cur' set but not used [-Wunused-but-set-variable]
    8 |     int n, ans = 0, l = 1, r = 1, cur = -1;
      |                                   ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...