답안 #170274

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
170274 2019-12-24T12:42:09 Z Akashi Art Exhibition (JOI18_art) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
using namespace std;

struct art{
    long long x;
    int y;
    bool operator < (const art &aux)const{
        if(x != aux.x) return x < aux.x;
        return y < aux.y;
    }
};

int n;
art a[500005];

int main()
{
    scanf("%d", &n);

    for(int i = 1; i <= n ; ++i)
        scanf("%lld%d", &a[i].x, &a[i].y);

    sort(a + 1, a + n + 1);

    long long Sol = a[1].y, Sum = a[1].y;
    int j = 1;
    for(int i = 2; i <= n ; ++i){
        Sum = Sum + a[i].y - a[i].x + a[i - 1].x;
        while(j < i && Sum < Sum - a[j].y - a[j].x + a[j + 1].x){
            Sum = Sum - a[j].y - a[j].x;
            ++j;
            Sum += a[j].x;
        }
        Sol = max(Sol, Sum);
    }

    printf("%lld", Sol);

    return 0;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
art.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%d", &a[i].x, &a[i].y);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -