제출 #1148429

#제출 시각아이디문제언어결과실행 시간메모리
1148429minggaCoin Collecting (JOI19_ho_t4)C++20
100 / 100
24 ms1864 KiB
#include "bits/stdc++.h" using namespace std; #define ln "\n" #define pb push_back #define fi first #define se second #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define int long long const int mod = 1e9 + 7; const int inf = 2e18; const int N = 2e5 + 7; int n, a[N][2]; signed main() { cin.tie(0) -> sync_with_stdio(0); #define task "" if(fopen(task ".INP", "r")) { freopen(task ".INP", "r", stdin); freopen(task ".OUT", "w", stdout); } cin >> n; int ans = 0; for(int i = 1; i <= 2 * n; i++) { int x, y; cin >> x >> y; if(x > n) { ans += (x - n); x = n; } if(x < 1) { ans += (1 - x); x = 1; } if(y > 2) { ans += (y - 2); y = 2; } if(y < 1) { ans += (1 - y); y = 1; } a[x][y]++; } int d1 = 0, d2 = 0; for(int i = 1; i <= n; i++) { d1 += a[i][1] - 1; d2 += a[i][2] - 1; if(d1 > 0 and d2 < 0) { int ext = min(d1, -d2); ans += ext; d1 -= ext; d2 += ext; } if(d1 < 0 and d2 > 0) { int ext = min(-d1, d2); ans += ext; d1 += ext; d2 -= ext; } ans += abs(d1) + abs(d2); } cout << ans << ln; cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC; }

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

joi2019_ho_t4.cpp: In function 'int main()':
joi2019_ho_t4.cpp:21:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |                 freopen(task ".INP", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t4.cpp:22:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |                 freopen(task ".OUT", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...