답안 #96464

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
96464 2019-02-09T14:36:37 Z rajarshi_basu 지구 온난화 (NOI13_gw) C++14
0 / 40
1000 ms 24496 KB
#include <iostream>
#include <vector>
#include <set>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <complex>
#include <stack>
#include <set>

#define FOR(i,n) for (int i = 0;i<n;i++)
#define FORE(i, a, b) for (int i = a;i<= b;i++)
#define ll long long int
#define ff first
#define ss second
#define ii pair<int,int>
#define pb push_back
#define mp make_pair

using namespace std;

int* arr;
int N;


vector<ii> all;
void preProcess(){

	FOR(i,N){
		if(i==0)continue;
		if(arr[i] != arr[i-1]){
			all.pb(mp(min(arr[i],arr[i-1]),max(arr[i],arr[i-1]) -1));
		}
	}
}


// sl == sealevel
int query(int sl){
	int cnt = 0;
	FOR(i,all.size())if(sl >= all[i].ff and sl <= all[i].ss)cnt++;
	if(arr[0] > sl)cnt++;
	if(arr[N-1] > sl)cnt++;
	//if((arr[0] > sl and arr[N-1]>sl)or(arr[0] <= sl and arr[N-1] <= sl))cnt++;
	return cnt/2;
}

int gw(int nn,int *H){
	N = nn;
	ii crdcmprs[N];
	FOR(i,N)crdcmprs[i].ff = H[i],crdcmprs[i].ss = i;
	sort(crdcmprs,crdcmprs+N);
	arr = new int[N];
	int PtR = 0;
	FOR(i,N){
		if(i > 0 and crdcmprs[i].ff > crdcmprs[i-1].ff)PtR++;
		arr[crdcmprs[i].ss] = PtR;
	}
	int mx = 0;
	preProcess();
	//FOR(i,N)cout << arr[i] << " ";cout << endl;
	FOR(i,all.size()){
	//	cout << all[i].ff << " " << all[i].ss << endl;
	}
	FOR(i,min(crdcmprs[N-1].ff+1,N+2)){
		int val;
		mx = max(mx,val = query(i));
		cout << val << endl;
	}
	return mx;
}


int main(){
	int n;
	cin >> n;
	int h[n];
	FOR(i,n)cin >> h[i];
	cout << gw(n,h) << endl;
	return 0;
}

Compilation message

gw.cpp: In function 'int query(int)':
gw.cpp:16:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define FOR(i,n) for (int i = 0;i<n;i++)
gw.cpp:46:6:
  FOR(i,all.size())if(sl >= all[i].ff and sl <= all[i].ss)cnt++;
      ~~~~~~~~~~~~                 
gw.cpp:46:2: note: in expansion of macro 'FOR'
  FOR(i,all.size())if(sl >= all[i].ff and sl <= all[i].ss)cnt++;
  ^~~
gw.cpp: In function 'int gw(int, int*)':
gw.cpp:16:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define FOR(i,n) for (int i = 0;i<n;i++)
gw.cpp:67:6:
  FOR(i,all.size()){
      ~~~~~~~~~~~~                 
gw.cpp:67:2: note: in expansion of macro 'FOR'
  FOR(i,all.size()){
  ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 36 ms 3184 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1070 ms 3184 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1074 ms 24496 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1092 ms 24416 KB Time limit exceeded
2 Halted 0 ms 0 KB -