답안 #1071688

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1071688 2024-08-23T10:00:59 Z vjudge1 Art Exhibition (JOI18_art) C++17
0 / 100
1 ms 2396 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define nn "\n";
#define pb push_back
const int N = 1e6 + 8  , inf = 1e17 ;
int  n , m , q , a[N], b[N];
signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin>> n ;
    vector<pair<int,   int >> v ;
    int ok =-inf , mx1 =0 ;
    for(int i  = 1; i <= n; i++){
        cin>> a[i]>> b[i];
        mx1 = max(mx1 , b[i]);
        v.pb({a[i] , b[i]});
    }
    sort(v.begin() , v.end());
    int mx =-inf , pos =0  ;
    for(int i =0 ; i < v.size() ; i++){
        //cout << v[i].first << ' ' << v[i].second << nn
        if(v[i].second - v[i].first> mx ){
            mx = v[i].second - v[i].first;
            pos = i ;
        }
    }
    int S = v[pos].second  , mn = v[pos].first ;
    mx =mx1 ;
    for(int i = pos+1 ; i < v.size() ; i++){
        mx = max(mx , S + v[i].second - (v[i].first - mn) );
        S+=v[i].second;
    }
    cout << mx  ;

}

Compilation message

art.cpp: In function 'int main()':
art.cpp:20:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(int i =0 ; i < v.size() ; i++){
      |                    ~~^~~~~~~~~~
art.cpp:29:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(int i = pos+1 ; i < v.size() ; i++){
      |                         ~~^~~~~~~~~~
art.cpp:12:9: warning: unused variable 'ok' [-Wunused-variable]
   12 |     int ok =-inf , mx1 =0 ;
      |         ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 0 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 0 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 0 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 0 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -