Submission #282147

# Submission time Handle Problem Language Result Execution time Memory
282147 2020-08-24T04:10:15 Z 반딧불(#5757) None (JOI15_walls) C++17
0 / 100
3000 ms 4472 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, k;
ll a[200002], b[200002];
ll arr[100002];
ll ans[100002];

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", &arr[i]);

    for(int i=1; i<=k; i++){
        for(int j=1; j<=n; j++){
            if(a[j] <= arr[i] && arr[i] <= b[j]) continue;
            ll tmp;
            if(arr[i] < a[j]) tmp = arr[i] - a[j];
            else tmp = arr[i] - b[j];
            a[j] += tmp, b[j] += tmp, ans[j] += abs(tmp);
        }
    }
    for(int i=1; i<=n; i++){
        printf("%lld\n", ans[i]);
    }
}

Compilation message

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", &arr[i]);
      |                             ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Incorrect 41 ms 3960 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1648 ms 1784 KB Output is correct
2 Execution timed out 3070 ms 4472 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Incorrect 41 ms 3960 KB Output isn't correct
3 Halted 0 ms 0 KB -