제출 #1183451

#제출 시각아이디문제언어결과실행 시간메모리
1183451SmuggingSpunSnowball (JOI21_ho_t2)C++20
33 / 100
11 ms328 KiB
#include<bits/stdc++.h> #define taskname "B" using namespace std; typedef long long ll; template<class T>void minimize(T& a, T b){ if(a > b){ a = b; } } template<class T>void maximize(T& a, T b){ if(a < b){ a = b; } } const ll INF = 1e18; const int lim = 2e5 + 5; int n, q; namespace sub1{ void solve(){ vector<ll>x(n), min_x(n), max_x(n), ans(n, 0); for(int i = 0; i < n; i++){ cin >> x[i]; min_x[i] = max_x[i] = x[i]; } for(int _ = 0; _ < q; _++){ ll w; cin >> w; if(w > 0){ for(int i = n - 1; i > -1; x[i--] += w){ if(i == n - 1){ ans[i] += max(0LL, w - max_x[i] + x[i]); } else{ ans[i] += max(0LL, min(min_x[i + 1] - max_x[i], w - max_x[i] + x[i])); } } } else{ for(int i = 0; i < n; x[i++] += w){ if(i == 0){ ans[i] += max(0LL, -w - x[i] + min_x[i]); } else{ ans[i] += max(0LL, min(min_x[i] - max_x[i - 1], -w - x[i] + min_x[i])); } } } for(int i = 0; i < n; i++){ minimize(min_x[i], x[i]); maximize(max_x[i], x[i]); } } for(ll& v : ans){ cout << v << "\n"; } } } namespace sub2{ void solve(){ } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); } cin >> n >> q; if(max(n, q) <= 2000){ sub1::solve(); } else{ sub2::solve(); } }

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

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