Submission #52394

#TimeUsernameProblemLanguageResultExecution timeMemory
52394updown1Stove (JOI18_stove)C++17
100 / 100
37 ms2528 KiB
/* greedily remove gaps between people */ #include <bits/stdc++.h> using namespace std; typedef long long ll; #define For(i, a, b) for(int i=a; i<b; i++) #define ffi For(i, 0, N) #define ffj For(j, 0, M) #define ffa ffi ffj #define s <<" "<< #define w cout #define e "\n" #define pb push_back #define mp make_pair #define a first #define b second #define int ll const int MAXN=100000, INF=2000000000000000000; ///500,000,000 int N, K, inp[MAXN], out; priority_queue<int> gap; main() { //ifstream cin("test.in"); ios_base::sync_with_stdio(0); cin.tie(0); cin >> N >> K; ffi cin >> inp[i]; sort(inp, inp+N); For (i, 1, N+1) gap.push(inp[i] - inp[i-1]-1); out = inp[N-1]-inp[0]+1; For (i, 1, K) { int x = gap.top(); gap.pop(); out -= x; //w<< x<<e; } w<< out<<e; }

Compilation message (stderr)

stove.cpp:24:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
stove.cpp: In function 'int main()':
stove.cpp:7:22: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
 #define For(i, a, b) for(int i=a; i<b; i++)
                      ^
stove.cpp:8:13: note: in expansion of macro 'For'
 #define ffi For(i, 0, N)
             ^~~
stove.cpp:28:5: note: in expansion of macro 'ffi'
     ffi cin >> inp[i]; sort(inp, inp+N);
     ^~~
stove.cpp:28:24: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     ffi cin >> inp[i]; sort(inp, inp+N);
                        ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...