# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
390113 | 2021-04-15T11:11:14 Z | ahmet | 수열 (APIO14_sequence) | C++14 | 16 ms | 2956 KB |
#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<<" "; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | contestant found the optimal answer: 108 == 108 |
2 | Incorrect | 1 ms | 332 KB | contestant didn't find the optimal answer: 951 < 999 |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 332 KB | contestant didn't find the optimal answer: 1093726 < 1093956 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | contestant found the optimal answer: 610590000 == 610590000 |
2 | Correct | 1 ms | 332 KB | contestant found the optimal answer: 311760000 == 311760000 |
3 | Incorrect | 2 ms | 332 KB | declared answer doesn't correspond to the split scheme: declared = 138085112437, real = 1989216017013 |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 332 KB | contestant didn't find the optimal answer: 21419072 < 21503404 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 620 KB | contestant didn't find the optimal answer: 1794250000 < 1818678304 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 16 ms | 2956 KB | declared answer doesn't correspond to the split scheme: declared = 6442067499, real = 15032002091 |
2 | Halted | 0 ms | 0 KB | - |