제출 #1267822

#제출 시각아이디문제언어결과실행 시간메모리
1267822minhmc2019Rabbit Carrot (LMIO19_triusis)C++20
14 / 100
625 ms472 KiB
#include <bits/stdc++.h> #define FOR(i, l, r, x) for(int i = l; i <= r; i += x) #define FOD(i, l, r, x) for(int i = l; i >= r; i -= x) #define debug(x) cout << "[DEBUG]: " << #x << " = " << x << endl; #define BIT(x) (1 << (x)) #define int long long using namespace std; const int N = 2e5 + 5; const int mod = 1e9 + 7; const int inf = 1e18; int n, M, h[N]; inline bool isOn(int mask, int i) { return ((mask >> i) & 1LL); } void solve() { cin >> n >> M; FOR(i, 1, n, 1) cin >> h[i]; h[0] = 0; int ans = 0; FOR(mask, 0, BIT(n) - 1, 1) { int last_i = -1; bool isValid = true; // // debug(bitset<5>(mask)); FOR(i, 0, n - 1, 1) { if (!isOn(mask, i)) continue; // if (last_i == -1) { // last_i = i; // continue; // } bool can_move = (h[last_i + 1] + ((i - last_i) * M) >= h[i + 1]); if (!can_move) { // cout << "index: " << last_i << " " << i << endl; // cout << "height: " << h[last_i + 1] << " " << ((i - last_i) * M) << " " << h[i + 1] << endl << endl; isValid = false; break; } last_i = i; } if (isValid) { ans = max(ans, (int)__builtin_popcountll(mask)); } } cout << n - ans << endl; } signed main() { #define name "task" if (ifstream(name".inp")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); }

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

triusis.cpp: In function 'int main()':
triusis.cpp:63:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |         freopen(name".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
triusis.cpp:64:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |         freopen(name".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...