답안 #1108382

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1108382 2024-11-04T03:09:33 Z vjudge1 Art Exhibition (JOI18_art) C++17
0 / 100
1 ms 336 KB
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define FOR(i, a, b) for(int i=(a), _b=(b); i<=_b; i++)
#define FORD(i, a, b) for(int i=(a), _b=(b); i>=_b; i--)
#define BIT(i, j) ((i>>j)&1)
#define pb push_back
#define ii pair<ll, ll>
#define pii pair<ll, ii>
#define fi first
#define se second
#define task "task"

const ll inf = 1e18;
const ll mod = 1e9+7;
const ll N = 500005;
const ll M = 50005;

ll n, s[N], ans, prefix[N], t;
ii a[N];
void solve()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i].fi >> a[i].se;
    }
    sort(a+1, a+n+1);
    for(int i = 1; i <= n; i++)
    {
        prefix[i] = max(prefix[i-1], a[i].fi - t);
        t += a[i].se;
        ans = max(ans, t + prefix[i-1] - a[i].fi);

    }
    cout << ans;

}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if(fopen(task".INP", "r"))
    {
        freopen(task".INP", "r", stdin);
        freopen(task".OUT", "w", stdout);
    }
    solve();
    return 0;
}


Compilation message

art.cpp: In function 'int main()':
art.cpp:45:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |         freopen(task".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:46:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |         freopen(task".OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -