Submission #56896

# Submission time Handle Problem Language Result Execution time Memory
56896 2018-07-13T05:55:53 Z 강태규(#1633) None (JOI15_walls) C++11
10 / 100
54 ms 8760 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int n, m;
int main() {
    scanf("%d%d", &n, &m);
    if (n > 1) return 0;
    int a, b;
    scanf("%d%d", &a, &b);
    llong ans = 0;
    for (int i = 0; i < m; ++i) {
        int p;
        scanf("%d", &p);
        if (p < a) {
            int x = a - p;
            a -= x;
            b -= x;
            ans += x;
        }
        else if (b < p) {
            int x = p - b;
            a += x;
            b += x;
            ans += x;
        }
    }
    printf("%lld\n", ans);
	return 0;
}

Compilation message

walls.cpp: In function 'int main()':
walls.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~
walls.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &a, &b);
     ~~~~~^~~~~~~~~~~~~~~~
walls.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &p);
         ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 43 ms 2508 KB Output is correct
3 Correct 41 ms 4360 KB Output is correct
4 Correct 54 ms 6292 KB Output is correct
5 Correct 43 ms 8248 KB Output is correct
6 Correct 42 ms 8684 KB Output is correct
7 Correct 36 ms 8704 KB Output is correct
8 Correct 42 ms 8760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 43 ms 2508 KB Output is correct
3 Correct 41 ms 4360 KB Output is correct
4 Correct 54 ms 6292 KB Output is correct
5 Correct 43 ms 8248 KB Output is correct
6 Correct 42 ms 8684 KB Output is correct
7 Correct 36 ms 8704 KB Output is correct
8 Correct 42 ms 8760 KB Output is correct
9 Incorrect 2 ms 8760 KB Output isn't correct
10 Halted 0 ms 0 KB -