Submission #677464

# Submission time Handle Problem Language Result Execution time Memory
677464 2023-01-03T11:54:25 Z mjhmjh1104 None (JOI15_walls) C++17
10 / 100
31 ms 972 KB
#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

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 time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 27 ms 284 KB Output is correct
3 Correct 26 ms 212 KB Output is correct
4 Correct 27 ms 212 KB Output is correct
5 Correct 31 ms 212 KB Output is correct
6 Correct 27 ms 212 KB Output is correct
7 Correct 21 ms 212 KB Output is correct
8 Correct 23 ms 972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 27 ms 284 KB Output is correct
3 Correct 26 ms 212 KB Output is correct
4 Correct 27 ms 212 KB Output is correct
5 Correct 31 ms 212 KB Output is correct
6 Correct 27 ms 212 KB Output is correct
7 Correct 21 ms 212 KB Output is correct
8 Correct 23 ms 972 KB Output is correct
9 Incorrect 6 ms 340 KB Output isn't correct
10 Halted 0 ms 0 KB -