제출 #1209664

#제출 시각아이디문제언어결과실행 시간메모리
1209664nguynGroup Photo (JOI21_ho_t3)C++20
0 / 100
0 ms328 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define F first #define S second #define pb push_back #define pii pair<int,int> const int N = 5e3 + 5; int n; int h[N]; int pos[N]; int f[N]; signed main(){ ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0) ; if (fopen("INP.INP" ,"r")) { freopen("INP.INP" ,"r" , stdin) ; freopen("OUT.OUT" , "w" , stdout) ; } cin >> n; for (int i = 1; i <= n; i++) { cin >> h[i]; pos[h[i]] = i; } for (int i = 1; i <= n; i++) f[i] = 1e9; for (int i = 1; i <= n; i++) { for (int j = 1; j <= i; j++) { int cost = 0; for (int k = i, cur = j; k > j; k--, cur++) { if (cur < pos[k]) cost += pos[k] - cur; } if (i < pos[j]) cost += pos[j] - i; f[i] = min(f[i], f[j - 1] + cost); } } cout << f[n]; }

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

Main.cpp: In function 'int main()':
Main.cpp:21:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         freopen("INP.INP" ,"r" , stdin) ;
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen("OUT.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...
#Verdict Execution timeMemoryGrader output
Fetching results...