답안 #704081

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
704081 2023-03-01T14:06:48 Z Potato3218 지구 온난화 (NOI13_gw) C++17
19 / 40
345 ms 65536 KB
#include <bits/stdc++.h>
using namespace std;
#define beegspeed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define pvi pair<int,vector<int>>
#define f first
#define s second
#pragma GCC optimize("Ofast")
#pragma GCC optimize("ffast-math,fno-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2,popcnt,bmi2")
 
vector<int> H;
unordered_map<int,vector<int>> um;
bool submerged[1000007];
vector<pvi> mp;
 
 
inline int readInt() {
    int x = 0;
    char ch = getchar();
    while (ch < '0' || ch > '9') ch = getchar_unlocked();
    while (ch >= '0' && ch <= '9'){
		x = (x << 3) + (x << 1) + ch - '0';
		ch = getchar_unlocked();
	}
    return x;
}
 
signed main(){
	beegspeed
		um.reserve(300000);
	int n = readInt();
	for(int i = 0; i < n; i++){
		int h = readInt();
		H.push_back(h);
		um[h].push_back(i);
	}
	for(auto& itr: um){
		mp.push_back(itr);
	}
	sort(mp.begin(), mp.end(), greater<pvi>());
	int ans = 0, curr = 0;
	for(auto itr: mp){
		for(auto island:itr.second){
			submerged[island] = true;
			//check if neighbouring sections are unsubmerged yet
			if(island == 0){
				if(!submerged[1]){
					++curr;
				}
			}
			else if(island == n-1){
				if(!submerged[n-2]) ++curr;
			}
			else{
				int p = (!submerged[island + 1]) + (!submerged[island- 1]);
				//if both aren't submerged evaluates to 2, if one of them is submerged evaluates to 1, else it's just 0
				--p;
				curr += p;
			}
		}
		ans = max(ans, curr);
	}
	cout<<ans;
}

Compilation message

gw.cpp:9:54: warning: bad option '-fffast-math' to pragma 'optimize' [-Wpragmas]
    9 | #pragma GCC optimize("ffast-math,fno-stack-protector")
      |                                                      ^
gw.cpp:9:54: warning: bad option '-ffno-stack-protector' to pragma 'optimize' [-Wpragmas]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
   11 | #pragma GCC target("avx2,popcnt,bmi2")
      |                                      ^
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-fffast-math' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad option '-ffno-stack-protector' to attribute 'optimize' [-Wattributes]
gw.cpp:11:38: warning: bad
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3028 KB Output is correct
2 Correct 2 ms 3028 KB Output is correct
3 Correct 2 ms 3028 KB Output is correct
4 Correct 2 ms 2900 KB Output is correct
5 Correct 1 ms 3028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 5704 KB Output is correct
2 Correct 6 ms 5704 KB Output is correct
3 Correct 6 ms 5704 KB Output is correct
4 Correct 5 ms 5704 KB Output is correct
5 Correct 6 ms 5704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 17728 KB Output is correct
2 Correct 31 ms 17852 KB Output is correct
3 Correct 40 ms 17728 KB Output is correct
4 Correct 40 ms 17732 KB Output is correct
5 Correct 45 ms 17824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 241 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 345 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -