Submission #282165

# Submission time Handle Problem Language Result Execution time Memory
282165 2020-08-24T05:24:18 Z 반딧불(#5757) None (JOI15_walls) C++17
10 / 100
3000 ms 2424 KB
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

typedef long long ll;

int n, k;
ll a[200002], b[200002];
ll arr[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", &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:16:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
walls.cpp:17:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |     for(int i=1; i<=n; i++) scanf("%lld %lld", &a[i], &b[i]);
      |                             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
walls.cpp:18:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |     for(int i=1; i<=k; i++) scanf("%lld", &arr[i]);
      |                             ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 40 ms 1912 KB Output is correct
3 Correct 45 ms 1912 KB Output is correct
4 Correct 46 ms 1912 KB Output is correct
5 Correct 37 ms 1916 KB Output is correct
6 Correct 37 ms 1912 KB Output is correct
7 Correct 31 ms 1912 KB Output is correct
8 Correct 40 ms 1944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1889 ms 1272 KB Output is correct
2 Execution timed out 3071 ms 2424 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 40 ms 1912 KB Output is correct
3 Correct 45 ms 1912 KB Output is correct
4 Correct 46 ms 1912 KB Output is correct
5 Correct 37 ms 1916 KB Output is correct
6 Correct 37 ms 1912 KB Output is correct
7 Correct 31 ms 1912 KB Output is correct
8 Correct 40 ms 1944 KB Output is correct
9 Correct 1889 ms 1272 KB Output is correct
10 Execution timed out 3071 ms 2424 KB Time limit exceeded
11 Halted 0 ms 0 KB -