답안 #95091

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
95091 2019-01-27T08:25:20 Z Rouge_Hugo Nizin (COCI16_nizin) C++14
100 / 100
67 ms 10232 KB
#include <bits/stdc++.h>
using namespace std;
long long  a[1000009];

int main()
{ios_base::sync_with_stdio(false);
cin.tie(NULL);
	int n;cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int re=0;
	long long  sum=0,sum1=0;
	for(int i=0,j=n-1;i<n,j>-1;i++,j--)
	{
		sum+=a[i];
		sum1+=a[j];
		while (sum!=sum1&&i<j)
		{
			if (sum>sum1)
			{re++;
				j--;
				sum1+=a[j];
				continue;
			}
			else if (sum1>sum)
			{
				re++;
				i++;
				sum+=a[i];
				continue;
			}
			else break;
		}
	}
cout<<re;
 return 0;

}

Compilation message

nizin.cpp: In function 'int main()':
nizin.cpp:15:21: warning: left operand of comma operator has no effect [-Wunused-value]
  for(int i=0,j=n-1;i<n,j>-1;i++,j--)
                    ~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 888 KB Output is correct
2 Correct 9 ms 1148 KB Output is correct
3 Correct 8 ms 1144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 3320 KB Output is correct
2 Correct 29 ms 4616 KB Output is correct
3 Correct 34 ms 5344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 7516 KB Output is correct
2 Correct 53 ms 8184 KB Output is correct
3 Correct 59 ms 9408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 64 ms 9720 KB Output is correct
2 Correct 67 ms 10224 KB Output is correct
3 Correct 65 ms 10232 KB Output is correct