Submission #844211

#TimeUsernameProblemLanguageResultExecution timeMemory
844211vjudge1Pod starim krovovima (COCI20_psk)C++17
50 / 50
1 ms436 KiB
#include<iostream> #include<vector> #include<iomanip> #include<algorithm> #include<map> #include<set> #include<climits> #include<numeric> #include<queue> #include<unordered_map> #include<string> #include<climits> #include<unordered_set> #include<bitset> #include<cstring> #include<cmath> #include<stack> #if 1 #define pb push_back #define st first #define nd second #define endl '\n' #define fio ios_base::sync_with_stdio(false);cin.tie(NULL); #define MAXN ((int)(2e5+5)) #define int long long int using namespace std; const int inf = 1e17 + 5; #endif void fileio(string s){ #ifndef ONLINE_JUDGE freopen((s+string(".in")).c_str(),"r",stdin); freopen((s+string(".out")).c_str(),"w",stdout); #endif } signed main(){ //fileio("test"); //fio; int n; cin >> n; set<pair<int, int> , greater<pair<int, int> > >s; int sum = 0; for(int i = 0; i < n; ++i){ int t, z; cin >> t >> z; sum += t; s.insert({z,i}); } int status[n]; memset(status, 0, sizeof(status)); int ans = n; for(auto it = s.begin(); it != s.end(); ++it){ int val = (*it).st, idx = (*it).nd; if(val < sum){ sum -= val; status[idx] = val; ans--; } else{ status[idx] = sum; ans--; break; } } cout << ans << endl; for(int i = 0; i < n; ++i)cout << status[i] << ' ';cout << endl; }

Compilation message (stderr)

psk.cpp: In function 'int main()':
psk.cpp:68:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   68 |     for(int i = 0; i < n; ++i)cout << status[i] << ' ';cout << endl;
      |     ^~~
psk.cpp:68:56: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   68 |     for(int i = 0; i < n; ++i)cout << status[i] << ' ';cout << endl;
      |                                                        ^~~~
psk.cpp: In function 'void fileio(std::string)':
psk.cpp:32:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         freopen((s+string(".in")).c_str(),"r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
psk.cpp:33:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         freopen((s+string(".out")).c_str(),"w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...