답안 #1108357

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1108357 2024-11-04T01:14:20 Z vjudge1 Art Exhibition (JOI18_art) C++17
0 / 100
1 ms 2384 KB
#include<bits/stdc++.h>
 #define int long long
using namespace std;

const int N = 1e6 + 5;

int n;

pair<int, int> item[N];

int p[N];

int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    #define Task "Flower"
    if(fopen(Task".inp","r")){
        freopen(Task".inp","r",stdin);
        freopen(Task".out","w",stdout);
    }
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> item[i].first >> item[i].second;
    }
    sort(item + 1, item + n + 1);
    for(int i = 1; i <= n; i++){
        p[i] = p[i - 1] + item[i].second;
    }
    int res = 0;
    for(int i = 1; i <= n; i++){
        res = max(res, p[i] + item[1].first - item[i].first);
    }
    cout << res;



}

Compilation message

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