제출 #855417

#제출 시각아이디문제언어결과실행 시간메모리
855417MilosMilutinovic서열 (APIO23_sequence)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define pb push_back #define fi first #define se second #define mp make_pair using namespace std; typedef long long ll; typedef pair<int,int> pii; int readint(){ int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } const int N=5000500; int n,a[N],val[N],pref[N]; vector<int> pos[N]; struct info{ ll mn_pref,mx_pref,mn_suff,mx_suff,tag; }st[4*N]; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]),pos[a[i]].pb(i); //build(1,1,n); for(int i=1;i<=n;i++) val[i]=1; int ans=0; for(int v=1;v<=n;v++){ if(pos[v].empty()) continue; for(int j:pos[v]) val[j]=0; // for(int j:pos[v]) modify(1,1,n,j,n,-1); for(int i=1;i<=n;i++) pref[i]=pref[i-1]+val[i]; for(int l=1;l<=n;l++){ int cnt=0; for(int r=l;r<=n;r++){ cnt+=(a[r]==v?1:0); if(abs(pref[r]-pref[l-1])<=cnt) ans=max(ans,cnt); } } // for(int j:pos[v]) modify(1,1,n,j,n,-1); for(int j:pos[v]) val[j]=-1; } printf("%d\n",ans); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

sequence.cpp: In function 'int main()':
sequence.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
sequence.cpp:32:29: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |  for(int i=1;i<=n;i++) scanf("%d",&a[i]),pos[a[i]].pb(i);
      |                        ~~~~~^~~~~~~~~~~~
/usr/bin/ld: /tmp/cc8AGtZC.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccF4L28C.o:sequence.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc8AGtZC.o: in function `main':
grader.cpp:(.text.startup+0x2a4): undefined reference to `sequence(int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status