제출 #1218907

#제출 시각아이디문제언어결과실행 시간메모리
1218907cpdreamerCake 3 (JOI19_cake3)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; const long long INF = 1e17; typedef long long ll; const ll MOD = (ll)1e9+7; #define P pair #define S second #define F first #define pb push_back #define V vector #define all(v) v.begin(), v.end() typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_multiset; void file() { freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); } void solve() { int n; cin>>n; int m; cin>>m; P<ll,ll>a[n+1]; for (int i=1;i<=n;i++) { cin>>a[i].S>>a[i].F; } sort(a+1,a+n+1); ll ans=LLONG_MIN; for (int i=1;i<=n;i++) { for (int j=i+m-1;j<=n;j++) { ll s=a[i].S+a[j].S; V<ll>v; for (int g=i+1;g<j;g++) { v.pb(a[g].S); } sort(all(v)); reverse(all(v)); for (int g=0;g<m-2;g++) { s+=v[g]; } s-=2*(a[j].F-a[i].F); ans=max(ans,s); } } cout<<ans<<endl; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); //file(); solve(); }#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; const long long INF = 1e17; typedef long long ll; const ll MOD = (ll)1e9+7; #define P pair #define S second #define F first #define pb push_back #define V vector #define all(v) v.begin(), v.end() typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_multiset; void file() { freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); } void solve() { int n; cin>>n; int m; cin>>m; P<ll,ll>a[n+1]; for (int i=1;i<=n;i++) { cin>>a[i].S>>a[i].F; } sort(a+1,a+n+1); ll ans=LLONG_MIN; for (int i=1;i<=n;i++) { for (int j=i+m-1;j<=n;j++) { ll s=a[i].S+a[j].S; V<ll>v; for (int g=i+1;g<j;g++) { v.pb(a[g].S); } sort(all(v)); reverse(all(v)); for (int g=0;g<m-2;g++) { s+=v[g]; } s-=2*(a[j].F-a[i].F); ans=max(ans,s); } } cout<<ans<<endl; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); //file(); solve(); }

컴파일 시 표준 에러 (stderr) 메시지

cake3.cpp:53:2: error: stray '#' in program
   53 | }#include <bits/stdc++.h>
      |  ^
cake3.cpp:53:12: error: 'bits' was not declared in this scope
   53 | }#include <bits/stdc++.h>
      |            ^~~~
cake3.cpp:53:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   53 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
cake3.cpp:53:12: error: 'bits' was not declared in this scope
   53 | }#include <bits/stdc++.h>
      |            ^~~~
cake3.cpp:53:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   53 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
cake3.cpp:53:12: error: 'bits' was not declared in this scope
   53 | }#include <bits/stdc++.h>
      |            ^~~~
cake3.cpp:53:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   53 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
cake3.cpp:53:12: error: 'bits' was not declared in this scope
   53 | }#include <bits/stdc++.h>
      |            ^~~~
cake3.cpp:53:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   53 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
cake3.cpp:53:12: error: 'bits' was not declared in this scope
   53 | }#include <bits/stdc++.h>
      |            ^~~~
cake3.cpp:53:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   53 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
cake3.cpp:53:12: error: 'bits' was not declared in this scope
   53 | }#include <bits/stdc++.h>
      |            ^~~~
cake3.cpp:53:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   53 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
cake3.cpp:53:12: error: 'bits' was not declared in this scope
   53 | }#include <bits/stdc++.h>
      |            ^~~~
cake3.cpp:53:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   53 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
cake3.cpp:53:12: error: 'bits' was not declared in this scope
   53 | }#include <bits/stdc++.h>
      |            ^~~~
cake3.cpp:53:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   53 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
cake3.cpp:53:12: error: 'bits' was not declared in this scope
   53 | }#include <bits/stdc++.h>
      |            ^~~~
cake3.cpp:53:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   53 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
cake3.cpp:53:3: error: 'include' does not name a type
   53 | }#include <bits/stdc++.h>
      |   ^~~~~~~
cake3.cpp:57:17: error: redefinition of 'const long long int INF'
   57 | const long long INF = 1e17;
      |                 ^~~
cake3.cpp:5:17: note: 'const long long int INF' previously defined here
    5 | const long long INF = 1e17;
      |                 ^~~
cake3.cpp:59:10: error: redefinition of 'const ll MOD'
   59 | const ll MOD = (ll)1e9+7;
      |          ^~~
cake3.cpp:7:10: note: 'const ll MOD' previously defined here
    7 | const ll MOD = (ll)1e9+7;
      |          ^~~
cake3.cpp:67:6: error: redefinition of 'void file()'
   67 | void file() {
      |      ^~~~
cake3.cpp:15:6: note: 'void file()' previously defined here
   15 | void file() {
      |      ^~~~
cake3.cpp:71:6: error: redefinition of 'void solve()'
   71 | void solve() {
      |      ^~~~~
cake3.cpp:19:6: note: 'void solve()' previously defined here
   19 | void solve() {
      |      ^~~~~
cake3.cpp:100:5: error: redefinition of 'int main()'
  100 | int main() {
      |     ^~~~
cake3.cpp:48:5: note: 'int main()' previously defined here
   48 | int main() {
      |     ^~~~
cake3.cpp: In function 'void file()':
cake3.cpp:16:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     freopen("input.txt","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
cake3.cpp:17:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     freopen("output.txt","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
cake3.cpp: In function 'void file()':
cake3.cpp:68:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   68 |     freopen("input.txt","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
cake3.cpp:69:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |     freopen("output.txt","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~