제출 #390113

#제출 시각아이디문제언어결과실행 시간메모리
390113ahmet수열 (APIO14_sequence)C++14
0 / 100
16 ms2956 KiB
#include <bits/stdc++.h> using namespace std; #define zaman cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds " #define rep(i,n) for(long long (i)=0;(i)<(n);++(i)) #define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i)) #define endl '\n' #define ll long long #define pb push_back #define pii pair<ll,ll> #define mp make_pair const int mx=2e5+6; int main(){ ios_base::sync_with_stdio(0);cin.tie(0); int n,k;cin >> n >> k; vector <int> a(n+1,0),p(n+1,0); ref(i,1,n)cin >> a[i]; ref(i,1,n){ p[i]=a[i]+p[i-1]; } int say=0; bitset <mx> b;ll ans=0,sum=0,top=0;b[n]=1; while(say<k){ sum=0;top=0; int son=1; priority_queue <pair<int,int> > pq; for(int i=1;i<=n;++i){ sum+=a[i];top=0; if(b[i]){ for(int j=son;j<=i;++j){ top+=a[j]; pq.push(mp(top*(sum-top),j)); } sum=0; son=i+1; continue; } } ans+=pq.top().first; b[pq.top().second]=1; //cout << pq.top().second << " " << pq.top().first << endl; ++say; } cout << ans<<endl; rep(i,n){ if(b[i])cout<<i<<" "; } }

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

sequence.cpp: In function 'int main()':
sequence.cpp:5:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    5 | #define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
      |                                   ^
sequence.cpp:17:2: note: in expansion of macro 'ref'
   17 |  ref(i,1,n)cin >> a[i];
      |  ^~~
sequence.cpp:5:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    5 | #define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
      |                                   ^
sequence.cpp:18:2: note: in expansion of macro 'ref'
   18 |  ref(i,1,n){
      |  ^~~
sequence.cpp:4:32: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
      |                                ^
sequence.cpp:45:2: note: in expansion of macro 'rep'
   45 |  rep(i,n){
      |  ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...