제출 #919690

#제출 시각아이디문제언어결과실행 시간메모리
919690Aiperiii수열 (APIO14_sequence)C++14
0 / 100
77 ms9248 KiB
#include <bits/stdc++.h> #define int long long #define ff first #define ss second #define pb push_back #define all(x) x.begin(),x.end() using namespace std; bool ok[500000]; signed main(){ ios_base::sync_with_stdio(); cin.tie(0);cout.tie(0); int n,k; cin>>n>>k; vector <int> a(n); for(int i=0;i<n;i++){ cin>>a[i]; } vector <vector <int> > v; vector <int> ids; for(int i=0;i<n;i++){ ids.pb(i); } v.pb(ids); vector <int> res; int ans=0; while(k--){ int mx=-10,div=0,ind=0; for(int j=0;j<v.size();j++){ if(ok[j])continue; vector <int> pr; int sum=0; for(int i=0;i<v[j].size();i++){ sum+=a[v[j][i]]; pr.pb(sum); } for(int i=0;i<pr.size();i++){ int x=pr.back()-pr[i]; if(mx<x*pr[i]){ mx=x*pr[i]; div=i; ind=j; } } } ok[ind]=1; vector <int> g1,g2; res.pb(v[ind][div]); for(int i=0;i<v[ind].size();i++){ if(i<=div)g1.pb(v[ind][i]); else g2.pb(v[ind][i]); } v.pb(g1);v.pb(g2); ans+=mx; } cout<<ans<<"\n"; for(auto x :res)cout<<x+1<<" "; cout<<"\n"; }

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

sequence.cpp: In function 'int main()':
sequence.cpp:30:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |       for(int j=0;j<v.size();j++){
      |                   ~^~~~~~~~~
sequence.cpp:34:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |          for(int i=0;i<v[j].size();i++){
      |                      ~^~~~~~~~~~~~
sequence.cpp:38:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |          for(int i=0;i<pr.size();i++){
      |                      ~^~~~~~~~~~
sequence.cpp:50:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |       for(int i=0;i<v[ind].size();i++){
      |                   ~^~~~~~~~~~~~~~
#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...