제출 #1163082

#제출 시각아이디문제언어결과실행 시간메모리
1163082AgentPenginArt Exhibition (JOI18_art)C++20
0 / 100
0 ms320 KiB
/**
 *    author:  AgentPengin ( Độc cô cầu bại )
 *    created: 23.12.2022 10:08:02
 *    too lazy to update time
**/
#include<bits/stdc++.h>

#define EL '\n'
#define fi first
#define se second
#define NAME "TASK"
#define ll long long
#define lcm(a,b) (a/gcd(a,b))*b
#define db(val) "["#val" = " << (val) << "] "
#define bend(v) (v).begin(),(v).end()
#define sz(v) (int)(v).size()
#define ex exit(0)
#define int ll

using namespace std;

const ll mod = 1e9 + 7;
const int inf = 0x1FFFFFFF;
const int MAXN = 5e5 + 5;

pair<int,int> a[MAXN];
int n,p[MAXN];

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    if (ifstream(NAME".inp")) {
        freopen(NAME".inp","r",stdin);
        freopen(NAME".out","w",stdout);
    }
    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++) {
    	p[i] = p[i - 1] + a[i].se;
    }
    
    int ans = 0;
    
    int cur = -p[0] + a[1].fi;
    
    for (int i = 1;i <= n;i++) {
    	ans = max(ans, p[i] - a[i].fi + cur);
 		cur = max(cur, -p[i - 1] + a[i].fi);
    	// for (int j = 1;j <= i;j++) {
    		// ans = max(ans, p[i] - p[j - 1] + a[j].fi - a[i].fi); 
    	// }
    }
    cout << ans;
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}
// agent pengin wants to take apio (with anya-san)

컴파일 시 표준 에러 (stderr) 메시지

art.cpp: In function 'int main()':
art.cpp:32:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         freopen(NAME".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
art.cpp:33:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         freopen(NAME".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...