제출 #302429

#제출 시각아이디문제언어결과실행 시간메모리
302429UserIsUndefined쌀 창고 (IOI11_ricehub)C++14
17 / 100
246 ms1852 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; int besthub(int R, int L, int X[], long long B) { int low = 0; int high = R*2; while(low < high){ int mid = (high+low)/2; // cout << mid << " " << low << " " << high << endl; long long sum = 0; long long now = mid/2; long long pluss = mid - mid/2 - 1; long long mines = mid - (pluss + 1); // cout << "lenth " << mid << endl; // cout << now << " << now " << pluss << " << pluse " << mines << " << mines " << endl; // for (int i = 0 ; i < mid ; i++){ // sum+= llabs(X[now] - X[i]); // } // cout << "first sum " << sum << endl; // cout << "B" << B << endl; // if (sum <= B){ // // low = mid + 1; // continue; // } int good = false; // cout << "len = " << mid << endl; // cout << "sums are : " << endl; for (int i = now ; i + pluss < R ; i++){ long long sum = 0; // cout << "middation " << i << endl; // cout << "from " << i - mines << " to " << i + pluss << endl; for (int j = i - mines ; j <= i + pluss ; j++){ sum+= llabs(X[j] - X[i]); } // cout << sum << endl; // int bye = X[i - mines - 1]; //// cout << "bye " << bye << endl; // sum-= llabs(X[i-1] - bye); //// cout << "sum without bye " << sum << endl; // int hello = X[i + pluss]; //// cout << "hello " << hello << endl; // sum+= llabs(X[i] - hello); //// cout << "sum with hello " << sum << endl; // // sum+= llabs(X[i] - X[i-1])*(mines - 1); // //// cout << "sum with pre" << sum << endl; // // sum-= llabs(X[i] - X[i-1])*(pluss - 1); // //// cout << "sum without after" << sum << endl; // cout << "new sum " << sum << endl; if (sum <= B){ low = mid + 1; good = true; break; } } // cout << "\n\n\n"; if (good)continue; high = mid - 1; } int best = low - 1; // for (int i = max(low - 5, 0) ; i <= min(low + 5, R) ; i++){ // long long sum = 0; // // long long now = X[i/2]; // // long long pluss = i - i/2 - 1; // // long long mines = i - pluss + 1; // // cout << "for " << i << endl; // // cout << "sums are :\n"; // // // for (int j = 0 ; j < i ; j++){ // sum+= llabs(now - X[j]); // } // // cout << sum << endl; // // if (sum <= B){ // best = i; // continue; // } // // int good = false; // // // for (int j = now + 1 ; j + pluss - 1 < R ; j++){ // int bye = X[j - mines]; // sum-= llabs(X[j-1] - bye); // int hello = X[j + pluss]; // sum+= llabs(X[j] - hello); // // sum+= llabs(X[j] - X[j-1])*mines; // // sum-= llabs(X[j] - X[j-1])*(pluss - 1); // // cout << sum << endl; // // if (sum <= B){ // best = i; // good = true; // break; // } // // } // // if (good)continue; // } return best; }

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

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:21:19: warning: unused variable 'sum' [-Wunused-variable]
   21 |         long long sum = 0;
      |                   ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...