Submission #677483

#TimeUsernameProblemLanguageResultExecution timeMemory
67748379brue방벽 (JOI15_walls)C++17
10 / 100
3056 ms3636 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, k; ll a[200002], b[200002]; ll pnt[200002]; ll ans[200002]; int main(){ scanf("%d %d", &n, &k); for(int i=1; i<=n; i++) scanf("%lld %lld", &a[i], &b[i]); for(int i=1; i<=k; i++) scanf("%lld", &pnt[i]); for(int i=1; i<=n; i++){ for(int j=1; j<=k; j++){ if(pnt[j] < a[i]){ ans[i] += a[i] - pnt[j]; b[i] -= (a[i] - pnt[j]); a[i] = pnt[j]; } else if(b[i] < pnt[j]){ ans[i] += pnt[j] - b[i]; a[i] += (pnt[j] - b[i]); b[i] = pnt[j]; } } printf("%lld\n", ans[i]); } }

Compilation message (stderr)

walls.cpp: In function 'int main()':
walls.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
walls.cpp:14:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     for(int i=1; i<=n; i++) scanf("%lld %lld", &a[i], &b[i]);
      |                             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
walls.cpp:15:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     for(int i=1; i<=k; i++) scanf("%lld", &pnt[i]);
      |                             ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...