제출 #405005

#제출 시각아이디문제언어결과실행 시간메모리
405005nicolaalexandraA Difficult(y) Choice (BOI21_books)C++14
100 / 100
4 ms328 KiB
#include<bits/stdc++.h> #include"books.h" #define DIM 100010 using namespace std; int n,k,s,i; long long a; long long v[DIM],d[DIM]; void solve(int n, int k, long long a, int s) { int i; long long sum = 0; for (i=1;i<=k;i++){ d[i] = skim(i); sum += d[i]; } if (sum > 2*a){ impossible(); return; } vector <int> ans; if (sum >= a){ for (i=1;i<=k;i++) ans.push_back(i); answer(ans); return; } sum -= d[k]; int st = k, dr = n, poz = n+1; long long val; while (st <= dr){ int mid = (st + dr) >> 1; long long nr = skim (mid); d[mid] = nr; if (nr >= a){ poz = mid, val = nr; dr = mid-1; } else st = mid+1; } if (poz <= n && sum + val >= a && sum + val <= 2*a){ ans.push_back(poz); for (i=1;i<k;i++) ans.push_back(i); } else { sum += d[k]; int st = 1, dr = poz-1; while (st <= k && sum < a){ sum -= d[st]; if (!d[dr]) d[dr] = skim(dr); sum += d[dr]; st++, dr--; } if (sum < a || sum > 2*a){ impossible(); return; } for (i=st;i<=k;i++) ans.push_back(i); for (i=dr+1;i<poz;i++) ans.push_back(i); } sort (ans.begin(),ans.end()); answer(ans); }

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

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:46:25: warning: 'val' may be used uninitialized in this function [-Wmaybe-uninitialized]
   46 |     if (poz <= n && sum + val >= a && sum + val <= 2*a){
      |                     ~~~~^~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...