제출 #683237

#제출 시각아이디문제언어결과실행 시간메모리
683237Github구경하기 (JOI13_watching)C++14
100 / 100
222 ms15220 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; #define speedup ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n, p, q; vector<int> events; bool simulate(int w){ int dp[n+1][p+1]; for (int i = 0; i <= n; i++){ for (int j = 0; j <= p; j++){ dp[i][j] = 1e9; } } dp[0][0] = 0; int lastp = 1, lastq = 1; for (int i = 1; i <= n; i++){ while (events[i] - events[lastp] >= w){ lastp++; } while (events[i] - events[lastq] >= 2*w){ lastq++; } for (int j = 0; j <= p; j++){ dp[i][j] = min(dp[i][j], dp[lastq-1][j]+1); if (j > 0){ dp[i][j] = min(dp[i][j], dp[lastp-1][j-1]); } } } int mn = 1e9; for (int i = 0; i <= p; i++){ mn = min(mn, dp[n][i]); } return (mn <= q); } int main(){ speedup int arr[10][10]; cin >> n >> p >> q; if (p+q >= n){ cout << 1 << endl; return 0; } events.resize(n+1); events[0] = 0; for (int i = 1; i <= n; i++){ cin >> events[i]; } sort(events.begin(), events.end()); int low = 1, high = 1e9, mid, ans = 1e9; while (high >= low){ mid = (high+low)/2; if (simulate(mid)){ ans = mid; high = mid-1; }else{ low = mid+1; } } cout << ans << endl; return 0; }

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

watching.cpp: In function 'int main()':
watching.cpp:43:9: warning: unused variable 'arr' [-Wunused-variable]
   43 |     int arr[10][10];
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...