Submission #339690

#TimeUsernameProblemLanguageResultExecution timeMemory
339690HazemPreokret (COCI19_preokret)C++14
50 / 50
1 ms364 KiB
/* 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 (stderr)

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]);
      |         ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...