Submission #1228732

#TimeUsernameProblemLanguageResultExecution timeMemory
1228732khoinguArt Exhibition (JOI18_art)C++20
0 / 100
0 ms320 KiB
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define fi(i,a,b) for(int i = a; i <= b; i ++)
#define fi   first
#define se   second
using namespace std;
const long long maxN = 5e5 + 5, INF = 1e17;

int n;
vector <pair<int, int>> a;

signed main() {
    if (fopen("task.inp", "r")) {
        freopen("task.inp", "r", stdin);
        freopen("task.out", "w", stdout);
    }
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i ++) {
        int x, y; cin >> x >> y;
        a.push_back({x, y});
    }
    sort(a.rbegin(), a.rend());
    int res = -INF;
    for(int i = 0; i < n; i ++) {
        int tmp = a[i].se;
        for(int j = i + 1; j < n; j ++) {
            tmp += a[j].se;
            res = max(res, tmp - a[i].fi + a[j].fi);
        }
    }
    cout << res;
}

Compilation message (stderr)

art.cpp:5: warning: "fi" redefined
    5 | #define fi   first
      | 
art.cpp:4: note: this is the location of the previous definition
    4 | #define fi(i,a,b) for(int i = a; i <= b; i ++)
      | 
art.cpp: In function 'int main()':
art.cpp:15:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         freopen("task.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:16:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         freopen("task.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...