답안 #209111

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
209111 2020-03-13T08:29:02 Z ArKCa Nizin (COCI16_nizin) C++17
100 / 100
122 ms 8184 KB
 #include<bits/stdc++.h>
#define  f1   first
#define  s2   second
#define  pb   push_back
#define  pob  pop_back
#define  int  ll
#define  ll   long long 
#define  PII  pair<int,int> 
#define  N    1000006
#define  mod  1000000007

using namespace std;


int n,arka,on,arkasum,onsum,ans;
int dizi[N];
int32_t main(){	    
	 // freopen("a.gir","r",stdin);
	// freopen("a.cik","w",stdout);
   //
  // 
	scanf("%lld" ,&n);
	for(int i=0;i<n;i++){
		scanf("%lld",&dizi[i]);
	}
	arka=0;
	on=n-1;
	arkasum=0;
	onsum=0;
	while(on>arka){
		if(dizi[on]==dizi[arka]){
			on--;
			arka++;
			arkasum=0;
			onsum=0;
			continue;
		}
		arkasum+=dizi[arka];
		arka++;
		onsum+=dizi[on];
		on--;		
		while(arkasum!=onsum && on>=arka ){
			// printf("%lld %lld %lld %lld\n",on,arka,onsum,arkasum );
			if(onsum>arkasum){
				arkasum+=dizi[arka];
				arka++;
			}
			else{
				onsum+=dizi[on];
				on--;
			}
			ans++;

			// printf("%lld %lld %lld %lld\n\n",on,arka,onsum,arkasum );

		}
		if(arkasum!=onsum && on<arka)ans++;
		arkasum=0;
		onsum=0;
	}
	printf("%lld\n", ans);

}


Compilation message

nizin.cpp: In function 'int32_t main()':
nizin.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld" ,&n);
  ~~~~~^~~~~~~~~~~~
nizin.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&dizi[i]);
   ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 888 KB Output is correct
2 Correct 16 ms 1144 KB Output is correct
3 Correct 16 ms 1144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 3064 KB Output is correct
2 Correct 55 ms 3576 KB Output is correct
3 Correct 62 ms 4216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 90 ms 6244 KB Output is correct
2 Correct 98 ms 6520 KB Output is correct
3 Correct 115 ms 7292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 122 ms 8140 KB Output is correct
2 Correct 118 ms 8184 KB Output is correct
3 Correct 122 ms 8184 KB Output is correct