답안 #339690

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
339690 2020-12-25T23:33:26 Z Hazem Preokret (COCI19_preokret) C++14
50 / 50
1 ms 364 KB
/*
ID: tmhazem1
LANG: C++14
TASK: pprime
*/

#include <bits/stdc++.h>
using namespace std;

#define S second
#define F first
#define LL long long
const int N = 2e5 + 10;


LL LINF = 100000000000000000;
LL INF = 1000000000;

int a[N];
int cnt[N][3];

int main()
{
    //freopen("out.txt","w",stdout);
    int n,ties = 1,mx = 0,cur = 1;
    scanf("%d",&n);    

    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        cnt[i][1] = cnt[i-1][1]+(a[i]==1);
        cnt[i][2] = cnt[i-1][2]+(a[i]==2);

        if(a[i]==a[i-1])cur++;
        else cur = 1;
        if(cnt[i-cur][a[i]]<cnt[i-cur][3-a[i]]&&cnt[i][a[i]]>cnt[i][3-a[i]])mx = max(mx,cur);
        ties += cnt[i][1]==cnt[i][2];
    }

    printf("%d %d\n%d\n%d\n",cnt[n][1],cnt[n][2],ties,mx);
}       

Compilation message

preokret.cpp: In function 'int main()':
preokret.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   26 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
preokret.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   29 |         scanf("%d",&a[i]);
      |         ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct