답안 #337626

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
337626 2020-12-21T09:45:45 Z kutbilim_one 금 캐기 (IZhO14_divide) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define all(x) x.begin(),x.end()
#define int long long

const int MAXN 100100; 
int x[MAXN], g[MAXN], d[MAXN], n;
int prg[MAXN], prd[MAXN], mn[MAXN];
int ans;
 
int search(int i, int E){
   	int l = 1, r = i, pos = 1;
  	while(l < r){
    	int m = (l+r)<<1;
     	if(mn[m] <= E) r = m;
      	else l = m+1;
   	}
  	return r;
}
 
signed main(){
   	ios_base::sync_with_stdio(false);
   	cin.tie(nullptr);
   
   	cin >> n;
   	for(int i = 1; i <= n; i++)
     	cin >> x[i] >> g[i] >> d[i];
   
   	mn[0] = 1e18;
   	for(int i = 1; i <= n; i++){
     	prg[i] = g[i] + prg[i-1];
     	prd[i] = d[i] + prd[i-1];
     	mn[i] = min(mn[i-1], prd[i-1] - x[i]);
      
     	int left = search(i, prd[i] - x[i]);
     	ans = max(ans, prg[i] - prg[left-1]);
  	}
   
  	cout << ans << endl;
   
	return 0;
}

Compilation message

divide.cpp:9:16: error: expected initializer before numeric constant
    9 | const int MAXN 100100;
      |                ^~~~~~
divide.cpp:10:7: error: 'MAXN' was not declared in this scope
   10 | int x[MAXN], g[MAXN], d[MAXN], n;
      |       ^~~~
divide.cpp:10:16: error: 'MAXN' was not declared in this scope
   10 | int x[MAXN], g[MAXN], d[MAXN], n;
      |                ^~~~
divide.cpp:10:25: error: 'MAXN' was not declared in this scope
   10 | int x[MAXN], g[MAXN], d[MAXN], n;
      |                         ^~~~
divide.cpp:11:9: error: 'MAXN' was not declared in this scope
   11 | int prg[MAXN], prd[MAXN], mn[MAXN];
      |         ^~~~
divide.cpp:11:20: error: 'MAXN' was not declared in this scope
   11 | int prg[MAXN], prd[MAXN], mn[MAXN];
      |                    ^~~~
divide.cpp:11:30: error: 'MAXN' was not declared in this scope
   11 | int prg[MAXN], prd[MAXN], mn[MAXN];
      |                              ^~~~
divide.cpp: In function 'long long int search(long long int, long long int)':
divide.cpp:18:10: error: 'mn' was not declared in this scope; did you mean 'm'?
   18 |       if(mn[m] <= E) r = m;
      |          ^~
      |          m
divide.cpp:15:23: warning: unused variable 'pos' [-Wunused-variable]
   15 |     int l = 1, r = i, pos = 1;
      |                       ^~~
divide.cpp: In function 'int main()':
divide.cpp:30:14: error: 'x' was not declared in this scope
   30 |       cin >> x[i] >> g[i] >> d[i];
      |              ^
divide.cpp:30:22: error: 'g' was not declared in this scope
   30 |       cin >> x[i] >> g[i] >> d[i];
      |                      ^
divide.cpp:30:30: error: 'd' was not declared in this scope
   30 |       cin >> x[i] >> g[i] >> d[i];
      |                              ^
divide.cpp:32:5: error: 'mn' was not declared in this scope; did you mean 'n'?
   32 |     mn[0] = 1e18;
      |     ^~
      |     n
divide.cpp:34:7: error: 'prg' was not declared in this scope
   34 |       prg[i] = g[i] + prg[i-1];
      |       ^~~
divide.cpp:34:16: error: 'g' was not declared in this scope
   34 |       prg[i] = g[i] + prg[i-1];
      |                ^
divide.cpp:35:7: error: 'prd' was not declared in this scope
   35 |       prd[i] = d[i] + prd[i-1];
      |       ^~~
divide.cpp:35:16: error: 'd' was not declared in this scope
   35 |       prd[i] = d[i] + prd[i-1];
      |                ^
divide.cpp:36:39: error: 'x' was not declared in this scope
   36 |       mn[i] = min(mn[i-1], prd[i-1] - x[i]);
      |                                       ^