Submission #677464

#TimeUsernameProblemLanguageResultExecution timeMemory
677464mjhmjh1104방벽 (JOI15_walls)C++17
10 / 100
31 ms972 KiB
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

int n, m;
vector<pair<int, int>> v;
long long res;

int main() {
    scanf("%d%d", &n, &m);
    v.resize(n);
    for (auto &i: v) scanf("%d%d", &i.first, &i.second);
    for (int i = 0; i < m; i++) {
        int x;
        scanf("%d", &x);
        if (v[0].first <= x && x <= v[0].second) continue;
        if (v[0].first > x) res += v[0].first - x, v[0].second -= v[0].first - x, v[0].first = x;
        if (v[0].second < x) res += x - v[0].second, v[0].first += x - v[0].second, v[0].second = x;
    }
    printf("%lld", res);
}

Compilation message (stderr)

walls.cpp: In function 'int main()':
walls.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
walls.cpp:14:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     for (auto &i: v) scanf("%d%d", &i.first, &i.second);
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
walls.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%d", &x);
      |         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...