답안 #987675

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
987675 2024-05-23T10:56:09 Z Tsagana Art Exhibition (JOI18_art) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>

#define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(x) x.begin(), x.end()
#define int long long
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define F first
#define S second

using namespace std;

void solve () {
	int n; cin >> n;
	pair<int, int> a[500001];
	for (int i = 0; i < n; i++)
	cin >> a[i].F >> a[i].S;
	sort(a, a + n);
	dp[0] = a[0].s;
	for (int i = 1; i < n; i++) {
		dp[i] = max(a[i].S, dp[i - 1] + a[i - 1].F + a[i].S - a[i].F);
		ans = max(ans, dp[i]);
	}
	cout << ans << '\n';
}
signed main() {IOS solve(); return 0;}

Compilation message

art.cpp: In function 'void solve()':
art.cpp:22:2: error: 'dp' was not declared in this scope
   22 |  dp[0] = a[0].s;
      |  ^~
art.cpp:22:15: error: 'struct std::pair<long long int, long long int>' has no member named 's'
   22 |  dp[0] = a[0].s;
      |               ^
art.cpp:25:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   25 |   ans = max(ans, dp[i]);
      |   ^~~
      |   abs
art.cpp:27:10: error: 'ans' was not declared in this scope; did you mean 'abs'?
   27 |  cout << ans << '\n';
      |          ^~~
      |          abs