제출 #1034028

#제출 시각아이디문제언어결과실행 시간메모리
1034028vjudge1Art Exhibition (JOI18_art)C++14
컴파일 에러
0 ms0 KiB
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,fma,lzcnt,popcnt")
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define ii pair<int,int>
#define ill pair<ll,ll>
#define el cout<<'\n'
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define int long long
const ll mod=1e9+7;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
const int nmax=5e5;

void add ( int&a , int b ) { if ((a+=b) > mod ) a -= mod ; }
void sub ( int&a , int b ) { if ((a-=b) < 0 ) a += mod ; }

template<typename T> void chkmin(T& x, T y) {if(x > y) x = y;}
template<typename T> void chkmax(T& x, T y) {if(x < y) x = y;}

using namespace std;
ii a[nmax+5];
ll sum[nmax+5];
int val[nmax+5];
int pos[nmax+5];
int get(int x)
{
    int p=pos[x+1];
   // cout<<p<<" "<<;el;
    return (sum[p]-sum[x-1]+a[x].fi-a[p].fi);
}
signed main()
{
   ios::sync_with_stdio(0);
   cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   vector<pair<ll, ll>> art(n+1);
	for(i=1; i<=n; i++){
		cin >> art[i].fi >> art[i].se;
	}
	vector<ll> pre(n+1);
	sort(art.begin()+1, art.end());
	for(i=1; i<=n; i++){
		pre[i]=pre[i-1]+art[i].se;
	}
	ll maxi=LLONG_MIN, ans=0;
	for(i=1; i<=n; i++){
		maxi=max(maxi, art[i].fi-pre[i-1]);
		ans=max(ans, pre[i]-art[i].fi+maxi);
	}
	cout << ans;
}

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

art.cpp: In function 'int main()':
art.cpp:42:6: error: 'i' was not declared in this scope
   42 |  for(i=1; i<=n; i++){
      |      ^
art.cpp:47:6: error: 'i' was not declared in this scope
   47 |  for(i=1; i<=n; i++){
      |      ^
art.cpp:51:6: error: 'i' was not declared in this scope
   51 |  for(i=1; i<=n; i++){
      |      ^