제출 #404997

#제출 시각아이디문제언어결과실행 시간메모리
404997nicolaalexandraA Difficult(y) Choice (BOI21_books)C++14
0 / 100
2 ms200 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); 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 = k+1; while (sum < a){ sum -= d[st], sum += skim(dr); st++, dr++; } if (sum < a || sum > 2*a){ impossible(); return; } for (i=st;i<dr;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:45:25: warning: 'val' may be used uninitialized in this function [-Wmaybe-uninitialized]
   45 |     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...