제출 #135016

#제출 시각아이디문제언어결과실행 시간메모리
135016CaroLinda수열 (APIO14_sequence)C++14
0 / 100
3 ms508 KiB
#include <bits/stdc++.h> #define lp(i,a,b) for(int i=a;i<b;i++) #define pii pair<int,int> #define ll long long #define ff first #define ss second #define pb push_back #define mk make_pair const int inf = 0x3f3f3f3f ; const int MAXN = 12 ; using namespace std ; int n , k ; vector<pii> intervals ; ll pref[MAXN] , ans = 0 ; ll get(int i , int j) { return pref[j] - pref[i-1] ; } int main() { scanf("%d%d", &n , &k ) ; lp(i,1,n+1) scanf("%lld", &pref[i] ) ; lp(i,1,n+1) pref[i] += pref[i-1] ; intervals.pb( mk(1,n) ) ; lp(i,0,k) { pair<ll,int> ansK = mk(-1,-1) ; for( pii myInt : intervals ) lp(j,myInt.ff , myInt.ss) ansK = max(ansK , mk(get(myInt.ff,j)*get(j+1, myInt.ss), j) ) ; lp(j,0,intervals.size()) if( intervals[j].ff <= ansK.ff && intervals[j].ss >= ansK.ss ) { int beg=intervals[j].ff, en=intervals[j].ss ; intervals[j] = mk(beg,ansK.ss) ; intervals.pb(mk(ansK.ss+1,en)) ; break ; } ans += ansK.ff ; } printf("%lld\n" , ans ) ; }

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

sequence.cpp: In function 'int main()':
sequence.cpp:3:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define lp(i,a,b) for(int i=a;i<b;i++)
sequence.cpp:41:6:
   lp(j,0,intervals.size())
      ~~~~~~~~~~~~~~~~~~~~       
sequence.cpp:41:3: note: in expansion of macro 'lp'
   lp(j,0,intervals.size())
   ^~
sequence.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n , &k ) ;
  ~~~~~^~~~~~~~~~~~~~~~~~
sequence.cpp:26:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  lp(i,1,n+1) scanf("%lld", &pref[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...