답안 #164616

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
164616 2019-11-22T08:02:37 Z AKaan37 스카이라인 (IZhO11_skyline) C++17
0 / 100
2 ms 504 KB
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█
 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long lo;
typedef pair< lo,lo > PII;
 
#define fi first
#define se second
#define mp make_pair
#define int long long
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
 
const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
vector<int> v;

main(void){
	//~ freopen("skyline.in","r",stdin);
	//~ freopen("skyline.out","w",stdout);
	scanf("%lld",&n);
	FOR{
		scanf("%lld",&a[i]);
	}
	int bas=1;
	while(bas<=n-2){
		//~ cout<<bas<<" : : "<<n<<endl;
		while(a[bas]==0){
			bas++;
			if(bas==n-1)break;
			continue;
		}
		if(a[bas+1]>0 && a[bas+2]>0){
			int at=min(a[bas],min(a[bas+1],a[bas+2]));
			a[bas]-=at;
			a[bas+1]-=at;
			a[bas+2]-=at;
			//~ cout<<a[bas]<<" "<<a[bas+1]<<" "<<a[bas+2]<<endl;
			cev+=7*at;continue;
		}
		//~ cout<<"\n()()()"<<bas<<"()()"<<endl;
		if(a[bas]>0 && a[bas+2]>0){
			int yes=min(a[bas],a[bas+2]);
			a[bas]-=yes;
			a[bas+2]-=yes;
			cev+=5*yes;continue;
		}
		cev+=3*a[bas];a[bas]=0;bas++;
	}
	//~ cout<<cev<<endl;
	cev+=a[n-1]*3;
	cev+=a[n]*3;
	
	printf("%lld\n",cev);
	return 0;
}

Compilation message

skyline.cpp:42:10: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(void){
          ^
skyline.cpp: In function 'int main()':
skyline.cpp:45:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&n);
  ~~~~~^~~~~~~~~~~
skyline.cpp:47:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&a[i]);
   ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -